Using scrartcl
as my document class, tables are set in a slightly larger font size than my normal text (12pt vs. 11pt I suppose). How can I change the font size for tables document wide? At the moment I just add a \small
to all my tables.
-
2Are you sure something else isn't doing this? The KOMA classes don't change the fontsize of tables AFAIK.– Alan MunnCommented Jun 7, 2011 at 19:42
-
2As Alan said, this is not the expected bahaviour with the default settings, can you please add to your question a minimal working example illustrating the change in the font size that you mentioned?– Gonzalo MedinaCommented Jun 7, 2011 at 20:36
5 Answers
\makeatletter
\renewenvironment{table}{%
\if@tablecaptionabove\let\caption\captionabove
\else\let\caption\captionbelow\fi
\small\@float{table}%
}{%
\end@float
}
\makeatother
-
1Unfortunately this does not work for me. Is it possible that some of the packages I use, such as
longtable
,colortable
, orcaption
interfere with that?– IngoCommented Jun 7, 2011 at 19:56 -
1Please provide a minimal example. The source was copied from the
scrartcl.cls
. Commented Jun 8, 2011 at 5:08
You can use the environment hook provided by etoolbox
. The following code will change the table contents to \tiny
(well \tiny
may be better for the demonstration purpose though no one will really use it).
The hook is plugged at tabular
. Use \AtBeginEnvironment{table}{\tiny}
has no effect. And indeed if it has effect, you won't really want it, since it will chang the caption too. You may want to customize the caption by another package like caption
or ccaption`, rather than change it here.
Since you won't really use a dozen kinds of tabular environment, so call \AtBeginEnvironment
for those you use will be enough (for the sake of good typographic practice you should not use more than two type of tables, one for short, one for long).
\documentclass{article}
\usepackage{etoolbox}
\AtBeginEnvironment{tabular}{\tiny}
\begin{document}
Some text in normal text.
\begin{table}[ht]
\caption{A table}
\begin{tabular}{c}
Some text in table size
\end{tabular}
\end{table}
\end{document}
The solution by Marco, redefining the table
environment and inserting \small
is a good approach. However, it doesn't work yet. Of course it could not be tested, since no example has been given.
The macro \@floatboxreset
calls \normalsize
. This can be redefined using \small
instead or just omitting \normalsize
. To not affect other floats, also this can be done within the table
redefinition. I called \normalsize
at the end of the environment.
So, here's a compilable example which works as desired:
\documentclass[10pt]{scrartcl}
\makeatletter
\renewenvironment{table}{%
\if@tablecaptionabove\let\caption\captionabove
\else\let\caption\captionbelow\fi
\renewcommand* {\@floatboxreset}{%
\reset@font\@setminipage}
\small\@float{table}%
}{%
\end@float\normalsize
}
\makeatother
\begin{document}
Text in 10pt
\begin{table}[!htbp]
\begin{tabular}{l}
Text in 9pt
\end{tabular}
\end{table}
Text in 10pt
\end{document}
I returned to this question because I dealt with a very similar topic on LaTeX-Community.org today.
-
1You don't have to call
\normalsize
at the end of the environment. It is because\small
will be local to the group closed by\end
. Also for the[!htbp]
, I guess what you really want is[!h]
.– Yan ZhouCommented Jun 19, 2011 at 22:32 -
@Yan Zhou: I guess so, originally I didn't use
\normalsize
, just edited and added it because\@floatboxreset
used it. Should not hurt. ;-) And[!htbp]
or[!h]
doesn't matter, it's just an example and it did it. I don't like to show[!h]
because in my opinion justh
is usually too less.– Stefan Kottwitz ♦Commented Jun 19, 2011 at 22:44
One more easy way to do what you need is to write
\let\oldtabular\tabular
\renewcommand{\tabular}{\footnotesize\oldtabular}
If you use another table environment than tabular
(for instance, tabularx
), you should replace \tabular
by \tabularx
in the command:
\let\oldtabularx\tabularx
\renewcommand{\tabularx}{\footnotesize\oldtabularx}
This will not affect table captions. This answer will work for any document class and any definition of the tabular
environment.
The approached mentioned here are quite useful. Here is another short way to do that, just redefine the table environment as below:
\makeatletter
\renewenvironment{table}
{\@float{table} \small}
{\end@float}
\makeatother
-
1Cool, it doesn't work if you use table options though, like
\begin{table}[p]
. Commented May 1, 2020 at 22:45