0

I have created a table (two rows, four columns) in a seperate .tex file. The table is smaller than the text width, so I stretch it to the text width. Unfortunately, the font size is much bigger than the font size of the rest of my text. This also appears when I don't stretch the table.

How can I get the same font size of my table as with the rest of my text or is this not usual?

Here is my table (table.tex):

\renewcommand{\arraystretch}{1.5}
\begin{tabular}{cccc}\toprule
~ & \textbf{Col1} & \textbf{Col2} & \textbf{Col3} \\ \midrule
$\beta = 1$ & 1234 (0.01234) & 4.524 (0.2345) & -0.54 (0.0423) \\ \midrule
$\beta = 2$ & 0.0345 (0.023) & 0.0012(0.0125) & -0.0161 (0.0174) \\
\bottomrule 
\end{tabular} 

And I include the table in the following way:

\begin{table}[!htbp]
\caption[Caption]{This is my caption.}
\centering
\resizebox{\textwidth}{!}{\input{table}}
\end{table}
  • 1
    \resizebox stretches anything, so what do you expect? ;-) If you want to have a \textwidth wide table, use tabularx for example. And please don't post such fragments only. – user31729 Jul 8 '16 at 15:28
  • 1
    never use \resizebox on tables, otherwise you get what you describe. – David Carlisle Jul 8 '16 at 15:58
1

The following example will fix the problem:

\documentclass{article}

\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{lipsum}
\newcolumntype{C}{>{\small\centering\arraybackslash}X}


\begin{document}
\parindent=0pt
\renewcommand{\arraystretch}{1.5}
\lipsum[1-2]

\begin{table}[!htbp]
\caption[Caption]{This is my caption.}
\begin{tabularx}{\textwidth}{CCCC}\toprule
~ & \textbf{Col1} & \textbf{Col2} & \textbf{Col3} \\ \midrule
$\beta = 1$ & 1234 (0.01234) & 4.524 (0.2345) & -0.54 (0.0423) \\ \midrule
$\beta = 2$ & 0.0345 (0.023) & 0.0012(0.0125) & -0.0161 (0.0174) \\
\bottomrule 
\end{tabularx}
\end{table} 
\end{document}

The \resizebox will resize and will make the fonts bigger. Hence, use tabularx package with C column specifier. The C column specifier is defined using \newcolumntype command, which sets the content in center.

  • Thank you very much. This worked very well. I have another bigger table with 7 columns. Some of the columns are again centered but some are left aligned and for one column I'm using p{7cm}. This table is wider than the text width (and also pretty long so landscape does also not work) . If I'm using resizebox to resize it to text width the fonts get smaller but I think there is no way without making the fonts smaller (otherwise it does not fit into the page). How can I use your approach in this case (also for the left aligned and p{7cm} columns) ? – machinery Jul 8 '16 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.