Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Changing font size for a \newcolumntype, using array and dcolumn together

121 views
Skip to first unread message

Scott Waichler

unread,
May 9, 2005, 4:39:35 PM5/9/05
to
I would like to define a \newcolumntype with smaller font size. For
example, I have

\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}

\begin{longtable}[c]{d{2} d{1} d{1} d{2}}

How can I make the column contents \scriptsize? (Without dcolumn and
with centering it would be ">{\scriptsize}c". I found some previous
posts related to this but can't get anything to work.

Thanks,
Scott Waichler
scott.w...@pnl.gov

Lars Madsen

unread,
May 9, 2005, 5:09:05 PM5/9/05
to

here's hack someone once gave me to colorize dcolumns

\makeatletter
\newcolumntype{Q}[1]{>{\scriptsize\DC@{.}{.}{#1}}c<{\DC@end}}
\makeatother

don't ask why it works, it just does. ;-)


--
/daleif (remove RTFSIGNATURE for email)

David Carlisle

unread,
May 9, 2005, 5:16:48 PM5/9/05
to
"Scott Waichler" <scott.w...@pnl.gov> writes:

Strangely you assume the authors of the longtable, array and dcolumn
packages cooperate enough to make the things work together...

the D column type is defined on the last line of dcolumn.sty
by

\newcolumntype{D}[3]{>{\DC@{#1}{#2}{#3}}c<{\DC@end}}

since you are using lt the c column starts off in text mode rather than
math
so \scriptsize is legal in the cell entry so you can just do
\newcolumntype{S}[3]{>{\scriptsize\DC@{#1}{#2}{#3}}c<{\DC@end}}

If you were doing this for an array you'd want to drop \scriptsyle into
the math mode but the various parts of the number are all set in
different boxes so they can be measured so they are all separate math
expressions, something like
\newcolumntype{S}[3]{>{\everymath{\scriptstyle}\DC@{#1}{#2}{#3}}c<{\DC@end}}
probably works. (defined somewhere where @ is a letter.

actually the above is what you need to do if you just want to make one
column small, but your example shows the whole table uses d
columns. Making each cell \scriptsize individually isn't optimal in that
case, even without dcolumn complications, as you still get line spacing
from the current font size. Can't you just stick \scriptsize before the
start of the table?


David

Scott Waichler

unread,
May 9, 2005, 6:01:08 PM5/9/05
to
Thanks, this does work. The "c" for column centering seems odd in a
dcolumn thing, but I won't try to understand why it works.

Scott Waichler

unread,
May 9, 2005, 6:06:30 PM5/9/05
to
I would like some elements of the table to remain in normalsize, so to
make the rowheight consistent with font in the rows that are to be
smaller, I'm resigned to using the following:

\newcommand{\decreaserowspacing}{-5pt}
with row entries like this:

396.76 & 545536.1 & 145388.7 & 1.068 \\ [\decreaserowspacing]

Scott

David Carlisle

unread,
May 9, 2005, 6:25:44 PM5/9/05
to
"Scott Waichler" <scott.w...@pnl.gov> writes:

> Thanks, this does work. The "c" for column centering seems odd in a
> dcolumn thing,


dcolumn more or less takes over the whole cell so doesn't really use the
centering aspect of c but to get get its stuff into the cell at all
it's (much) easier to use >{..}c<{...} than to open up the array package
internals to get acces to a "raw" table cell.

> but I won't try to understand why it works.

it's all beautifully documented in dcolumn.dtx, don't you know:-)

David

0 new messages