167

What's the recommend way of changing the font size in a particular table? Is there a better way than enclosing all values with, for example, the \tiny function.

201

Scale down your table to the textwidth

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

\begin{table}
\resizebox{\textwidth}{!}{%
  \begin{tabular}{cc}
    Knuth & Lamport
  \end{tabular}}
\end{table}

\end{document}

then you have the optimal font size. However, all tabular lines are also scaled down which doesn't matter because it looks nicer.

  • Now if this would only work with text wrapping as well and eliminate the need to manually specify columns widths, that would be awesome. Is there a way to use your functionality and also have automatic text wrapping? – Veridian Aug 9 '13 at 2:57
  • 5
    use a tabularx with X columns – user2478 Aug 9 '13 at 20:50
  • I must report that with XeLaTeX it does work, but with LuaLaTeX does not. – djnavas Feb 10 '16 at 6:45
  • 3
    It was not stated but the caption, \caption{demo table}, and label, \label{tab:demo}, go outside of the \resizebox area. – Steven C. Howell Feb 1 '17 at 19:09
  • 2
    I have a table in landscape \begin{landscape}. When I used \textwidth for defining the width of the resized box, the resulting box had the width of the text of a portrait oriented page. For anybody having the same problem, use\linewidth instead of \textwidth, it solved the problem in my case. Source: tex.stackexchange.com/a/7686/118906 – a tiger Apr 26 '17 at 13:14
108

Write \tiny immediately after \begin{table}. If you don't use a (floating) table environment, enclose your (e.g.) tabular environment in a group and write \tiny after \begingroup.

\documentclass{article}

\begin{document}

\begin{table}
\tiny
\centering
\begin{tabular}{cc}
Knuth & Lamport
\end{tabular}
\end{table}

\end{document}

EDIT: To change the fontsize for all tables (or even floats of every type), one may use the floatrow package (this also saves typing \centering in every table):

\documentclass{article}

\usepackage{floatrow}
\DeclareFloatFont{tiny}{\tiny}% "scriptsize" is defined by floatrow, "tiny" not
\floatsetup[table]{font=tiny}

\begin{document}

\begin{table}
\begin{tabular}{cc}
Knuth & Lamport
\end{tabular}
\end{table}

\end{document}
  • 6
    Just one quick additional remark: whenever your figure/table has a caption, be sure to change the font size only after you've specified the caption. This is particularly important if you're specifying tiny or scriptsize for the font size. – Mico Aug 31 '11 at 17:26
  • Anyway to specify font sizes between \tiny and \small? \tiny is too small for me to read and \small is the same as normal font size – Veridian Aug 13 '13 at 0:16
  • 2
    @sphere How about \footnotesize? – lockstep Aug 13 '13 at 6:53
  • 1
    Dredging up the past... @Mico, I don't see this behaviour at all. None of my captions (specified with \caption) are affected in any way with a fontsize declaration before them inside a table environment. – a different ben Jan 21 '14 at 23:21

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.