Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a table that is just a little too wide for a 3.33" column. Is there a way to simply shrink the table a little to make it fit? I'm OK if the 10pt font becomes 9pt-something. Here is an example.

\begin{table}
\centering
\begin{tabular}{r|lll}
\multicolumn{1}{r}{}
& \multicolumn{1}{l}{Heading 1}
& \multicolumn{1}{l}{Heading 2}
& \multicolumn{1}{l}{Heading 3} \\ \cline{2-4}
Row 1 & Cell 1,1 & Cell 1,2 & Cell 1,3 \\
Row 2 & Cell 2,1 & Cell 2,2 & Cell 2,3
\end{tabular}
\end{table}
share|improve this question
4  
Why not just use \small or \footnotesize at the beginning of table environment? Box scaling also has disadvantage, tabular line will be slightly scaled. –  Leo Liu Feb 11 '11 at 18:07
1  
it make more sense to scale it exactly to linewidth, which is the same as using the best font size! –  Herbert Feb 11 '11 at 18:25
1  
@Herbert, it is not quite the same as using the best font size, due to optical scaling of the fonts. Ie, cmr10 at 90% scale is not the same as cmr9. Also, as Leo says, the weight of the tabular lines will not be completely consistent. –  Lev Bishop Feb 12 '11 at 1:08
    
I just tried \small after \begin{table}, and although it does the job, I like the output that \resizebox gives better. –  Nathan Farrington Feb 12 '11 at 3:30
    
@Lev: as I said, scaling is better than using a too small font size. And the line width will also be scaled down so that they are still proportional to the font. –  Herbert Feb 12 '11 at 5:26

3 Answers 3

up vote 42 down vote accepted

You can resize it using \resizebox{<width>}{<height>} from the graphics package. The column width is \columnwidth and you can select ! for the height to make it scale along with the width.

\usepackage{graphics}
% ...

\begin{table}
\centering
\resizebox{\columnwidth}{!}{%
\begin{tabular}{r|lll}
\multicolumn{1}{r}{}
& \multicolumn{1}{l}{Heading 1}
& \multicolumn{1}{l}{Heading 2}
& \multicolumn{1}{l}{Heading 3} \\ \cline{2-4}
Row 1 & Cell 1,1 & Cell 1,2 & Cell 1,3 \\
Row 2 & Cell 2,1 & Cell 2,2 & Cell 2,3
\end{tabular}%
}
\end{table}

Should the table include verbatim or similar material than \resizebox isn't good enough. You can use the {adjustbox}{width=\columnwidth} environment from the adjustbox package instead. It is based on the same graphicx code as \resizebox but allows for any content.

Please do not use the center environment in floats (figure, table), it generates an extra margin and doesn't always work. Use the \centering macro instead.

share|improve this answer
1  
I have changed the question (and my paper) to use the \centering macro, thanks. –  Nathan Farrington Feb 12 '11 at 3:16
    
This worked the best for me. Using either \columnwidth or \linewidth seemed to give exactly the same results. –  Nathan Farrington Feb 12 '11 at 3:29
    
@Nathan: Please note that \columnwidth should always be the width of the column. The \linewidth is the width of the text lines and is different depending if you are in single of double column mode. –  Martin Scharrer Feb 12 '11 at 9:19
    
@Martin: that is not correct. They have both the same value, \textwidth is the width of the onecolumn part –  Herbert Feb 12 '11 at 13:23
2  
@Martin: \columnwidth is correct for twocolumn mode, but \linewidth is the width of the current line, which can be smaller than \columnwidth, eg in a quotation environment in twocolumn mode which sets its own margins. –  Herbert Feb 12 '11 at 14:41

You can scale the whole table using \scalebox from the graphicx package.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{table}
\begin{center}
\scalebox{0.9}{
\begin{tabular}{r|lll}
\multicolumn{1}{r}{}
& \multicolumn{1}{l}{Heading 1}
& \multicolumn{1}{l}{Heading 2}
& \multicolumn{1}{l}{Heading 3} \\ \cline{2-4}
Row 1 & Cell 1,1 & Cell 1,2 & Cell 1,3 \\
Row 2 & Cell 2,1 & Cell 2,2 & Cell 2,3
\end{tabular}}
\end{center}
\end{table}
\end{document}
share|improve this answer
3  
I used \scalebox for years until I figured out that there is \resizebox! :-) You miss a % behind it. –  Martin Scharrer Feb 11 '11 at 18:00
    
@Martin I always tend to use scalebox, find it easier to use. –  Yiannis Lazarides Feb 11 '11 at 18:32
    
I have now tried both \scalebox and \resizebox, and I like \resizebox better because it seems to give a better end result. –  Nathan Farrington Feb 12 '11 at 3:27

you can resize it to exactly the linewidth:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\noindent\hrulefill

\smallskip\noindent
\resizebox{\linewidth}{!}{%
\begin{tabular}{r|lll}
\multicolumn{1}{r}{}
& \multicolumn{1}{l}{Heading 1}
& \multicolumn{1}{l}{Heading 2}
& \multicolumn{1}{l}{Heading 3} \\ \cline{2-4}
Row 1 & Cell 1,1 & Cell 1,2 & Cell 1,3 \\
Row 2 & Cell 2,1 & Cell 2,2 & Cell 2,3
\end{tabular}}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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