18

Hi I am trying the following code but only the first row (the headings) is being changed to the specified font size. How can I make the whole table's font size change?

\begin{table}[!htbp]
\fontsize{11}{9}
\centering
\begin{tabular}{p{2cm} | p{2cm} | p{2cm}}
\hline
\hline
\Result 1 & Result 2 & Result 3 \\ [0.2ex] 
\hline
22 & 34 & 12\\ 
\hline
65 & 43 & 55\\ 
\hline
42 & 76 & 23\\ [1ex] 
\hline
\end{tabular}
\end{table}
3
  • @MarioS.E. I tried that its still only resizing the first row
    – M9A
    May 1, 2013 at 14:04
  • Consider using the booktabs package, because it is awesome.
    – Werner
    May 1, 2013 at 14:06
  • @Matt9Atkins as posted it will not resize the font at all. If you are seeing a change in the first row you must have a font selection there, such as \textbf. May 1, 2013 at 14:50

3 Answers 3

20

Font size settings such as \fontsize{11}{9} do not take effect until \selectfont is issued so that should be

\fontsize{11}{9}\selectfont

But that selects an 11pt font on a 9pt baseline so the text will not fit in the allocated space and you will get irregular spaced lines. Perhaps you intended

\fontsize{9}{11}\selectfont

Or better

\small
9

If you have multiple tables (using tabular) in the document, to save you from some typing you can do the following:

\documentclass{article}
\usepackage{etoolbox}
\BeforeBeginEnvironment{tabular}{\begin{center}\small}
\AfterEndEnvironment{tabular}{\end{center}}
\usepackage{booktabs}
\usepackage{float}
\floatplacement{table}{!htbp}

\begin{document}
\begin{table}
\begin{tabular}{ccc}
\toprule
Result 1 & Result 2 & Result 3 \\
\midrule
22 & 34 & 12\\ 
65 & 43 & 55\\ 
42 & 76 & 23\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

As you can see, the table construction is cleaner now =).

1
  • I used this one but removed the \begin{center} from the \BeforeBeginEnvironment and did no \AfterEndEnvironment because it was causing the tables to have a lot of padding above and below when it came to how far captions were displayed. Nov 29, 2020 at 23:47
6

Or you can juste put a {\Large... your table... } like this...

\documentclass{article}
\begin{document}
\begin{center}
\begin{table}[!htbp]
\fontsize{11}{9}
\centering
{\Large %                                   <------ Here
\begin{tabular}{p{2cm} | p{2cm} | p{2cm}}
\hline
\hline
Result 1 & Result 2 & Result 3 \\ [0.2ex] 
\hline
22 & 34 & 12\\ 
\hline
65 & 43 & 55\\ 
\hline
42 & 76 & 23\\ [1ex] 
\hline
\end{tabular}
}%                                          <---- And here
\end{table}\end{center}
\end{document}

It's not very professional, but il works ;)

1
  • 1
    Why not very professional? Is there a disadvantage to using this simple method?
    – Pertinax
    Jun 1, 2017 at 21:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .