1

I have a table that is too wide to fit in a page. How to change the font size in a table?

enter image description here

This is the source code.

\documentclass[12pt]{article}

\usepackage{booktabs}
\usepackage{multirow}

\begin{document}

    \begin{table*}[ht]
    \caption{Dissemination Time and Success in ONE Simulation}
    %\vspace{-.25cm}
    \centering
    \begin{tabular}{l ccc c ccc c ccc c ccc}
    \toprule
    & \multicolumn{7}{c}{1K/2K byte budget} && \multicolumn{7}{c}{5K byte budget}\\
    \cmidrule{2-8} \cmidrule{10-16}
    & \multicolumn{3}{c}{success (\%)} && \multicolumn{3}{c}{time (s)} &&\multicolumn{3}{c}{success (\%)} && \multicolumn{3}{c}{time (s)} \\
    \addlinespace
    & FBF & Labeled & JSON && FBF & Labeled & JSON && FBF & Labeled & JSON  && FBF & Labeled & JSON\\
    \midrule
    {\em Manhattan} & 100\% & 67\% & 67\% && 1248 & 1820 & 2446 && 100\% & 100\% & 100\% && 675 & 583 & 1485\\
    {\em mini-Manhattan} & 27\% & 11\% & 16\% && 329 & 315 & 208 && 78\% & 53\% & 33\% && 263 & 364 & 308\\
    \bottomrule
    \end{tabular}
    \label{table:dissemination}
    \vspace{-.25cm}
    \end{table*}  
\end{document}
  • 1
    After \centering, you could revise as \scriptsize\makebox[\textwidth]{\begin{tabular}...\end{tabular}} or even \tiny if needed. – Steven B. Segletes Apr 15 '16 at 16:37
  • What is \multirow{2}{*}{\parbox[c]{.1\linewidth}{\centering }} supposed to do? Looks like it can just be omitted. Please state the dimensions of the text block -- especially its width. – Mico Apr 15 '16 at 16:55
  • @StevenB.Segletes -- wouldn't \scriptsize be better placed just before \begin{tabular}, inside the box? – barbara beeton Apr 15 '16 at 16:56
  • Please also tell us which document class you used for the two-column version of the document. – Mico Apr 15 '16 at 16:59
  • @barbarabeeton You are right in general, though in this particular instance, I do not think there is any difference – Steven B. Segletes Apr 15 '16 at 17:00
4

You can make the table fit if you (a) set reasonably tight page margins (say, 1" wide); (b) set the relative font size to \footnotesize (a 20% linear reduction from \normalsize), (c) get rid of the three empty columns and (d) use a tabular* environment (with width set to \textwidth) and let LaTeX figure out the amount of whitespace that can be inserted between the columns.

enter image description here

\documentclass[12pt]{article}
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters
\usepackage{booktabs,caption}
\begin{document}

\begin{table}[ht]
\captionsetup{skip=0.5\baselineskip,size=footnotesize}
\footnotesize
\setlength\tabcolsep{0pt} 
\caption{Dissemination Time and Success in ONE Simulation}
\label{table:dissemination}
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} *{12}{c}}
\toprule
& \multicolumn{6}{c}{1K/2K byte budget} 
& \multicolumn{6}{c}{5K byte budget}\\
\cmidrule{2-7} \cmidrule{8-13}
& \multicolumn{3}{c}{success (\%)} & \multicolumn{3}{c}{time (s)} 
& \multicolumn{3}{c}{success (\%)} & \multicolumn{3}{c}{time (s)} \\
\cmidrule{2-4} \cmidrule{5-7} \cmidrule{8-10} \cmidrule{11-13}
& FBF & Labeled & JSON & FBF & Labeled & JSON 
& FBF & Labeled & JSON & FBF & Labeled & JSON\\
\midrule
\em Manhattan & 100\% & 67\% & 67\% & 1248 & 1820 & 2446 & 100\% & 100\% & 100\% & 675 & 583 & 1485\\
\em mini-Manhattan & 27\% & 11\% & 16\% & 329 & 315 & 208 & 78\% & 53\% & 33\% & 263 & 364 & 308\\
\bottomrule
\end{tabular*}
\end{table}  
\end{document}
  • Incidentally, if there's a way to use a narrower header label than "Labeled", a lot of space could be freed up. This could be put to use to use a larger font size and/or create more (and more evenly distributed) intercolumn whitespace. – Mico Apr 15 '16 at 17:31

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.