1

Let's say I'd like to scale the following table down. It's actually much larger, but this will do as a minimal example. I've seen many solutions using resizebox, but that doesn't quite work in this case, as I need not only to scale down the tabular environments, but also the sub-captions.

\begin{table}[htb]
    \caption{Study 2: Summary of the answers to the demographics questionnaire.}\label{tab:study-2:demographics}

    \centering
    \subcaptionbox{A1: Have you studied music?}{
        \begin{tabular}{@{}rccc}
        \toprule
        & {\bf\small no}
        & {\bf\small informally}
        & {\bf\small formally} \\ \midrule
        {\bf\small beginners}       & {\bf 7} & 5 &       2  \\
        {\bf\small non-beginners}   &      0  & 1 & {\bf  9}  \\
        {\bf\small total}           &      7  & 6 & {\bf 11} \\ \bottomrule
        \end{tabular}
    }\quad
    \subcaptionbox{A2: Do you play a musical instrument?}{
        \begin{tabular}{ccc}
        \toprule
        {\bf\small no}
        & {\bf\small one}
        & {\bf\small more} \\ \midrule
        {\bf 10} & 3 &      1  \\
                0  & 2 & {\bf 8} \\
        {\bf 10} & 5 &      9  \\ \bottomrule
        \end{tabular}
    }
\end{table}

Can this even be done? Should I just export the table as a PDF and reimport it as a figure?

4
  • 1
    Off-topic: \bf is a deprecated command since more than 20 years. Replace it with \bfseries
    – user31729
    Dec 10 '17 at 16:22
  • Alright, but you got me excited there for a moment… :)
    – Morpheu5
    Dec 10 '17 at 16:24
  • 1
    Call me The One That Causes Excitement ;-)
    – user31729
    Dec 10 '17 at 16:27
  • 1
    @ChristianHupfer - Sure... :-)
    – Mico
    Dec 10 '17 at 16:54
1

Scaling tabular material using something like a \resizebox directive is almost invariably a poor solution.

By all means, do determine whether using either \small or \footnotesize succeeds in typesetting the tabular material without exceeding the width of the text block. However, unless you are openly contemptuous of your readers -- or if you don't care if you're perceived by your readers as being contemptuous of them -- don't try \scriptsize, let alone \tiny.

As Christian He-Who-Causes-Excitement [!] Hupfer has already pointed out in a comment, \bf is badly deprecated. In fact, it's no longer defined in the LaTeX kernel. Some document classes (such as the KOMA-Script classes and memoir) will crash if they encounter \bf, \it, \tt, and the like. Instead, use \bfseries, \itshape, \ttfamily, and so on.

Especially if your tabular-like environments contain quite a few columns, reducing the value of \tabcolsep (default value: 6pt) quite frequently is all that's needed to make the tabular material fit inside the text block. Suppressing the whitespace padding on the left and right hand edges of the tabular material, by inserting @{} directives, can also be useful.

If the material in each subcaptionbox is sufficiently voluminous or complex so as to make it impossible to place two (or more) such boxes next to each other, even after having tried \small and \footnotesize and having reduced the value of \tabcolsep, so be it. Start placing the subcaptions one below the other, rather than side by side.

Do study the following, modified, form of your code and determine whether it can serve as a template for your formatting needs.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{booktabs,subcaption,ragged2e}

\begin{document}
\begin{table}[p]
\caption*{Study 2: Summary of answers to demographics questionnaire.}
\label{tab:study-2:demographics}

\small % or \footnotesize, if necessary
\setlength\tabcolsep{4pt}  % default value: 6pt

    \subcaptionbox{A1: Have you studied music?}{%
    \begin{tabular}{@{}rccc@{}}
        \toprule
        & \bfseries no & \bfseries informally & \bfseries formally \\
        \midrule
        \bfseries  beginners     & \bfseries 7 & 5 & 2  \\
        \bfseries  non-beginners &  0          & 1 & \bfseries 9  \\
        \bfseries  total         &  7          & 6 & \bfseries 11 \\ \bottomrule
    \end{tabular}%
    }\hfill  % maximize the distance between the subcaptionboxes
    \subcaptionbox{\Centering A2: Do you play a musical instrument?}{%
    \begin{tabular}{@{}ccc@{}}
        \toprule
        \bfseries no & \bfseries one & \bfseries more \\ 
        \midrule
        \bfseries 10 & 3 & 1 \\
        0            & 2 & \bfseries 8 \\
        \bfseries 10 & 5 & 9 \\ 
        \bottomrule
    \end{tabular}%
    }
\end{table}
\end{document} 
8
  • Hey, thanks for the thorough reply. On using smaller font sizes, I tried that avenue but am I missing something or do I have to repeat \small for every cell? I tried using it right at the beginning of the table environment, and it didn't quite work (as in, it didn't work at all). Other than that, unfortunately the problem I'm facing is that the tables are long, rather than wide -- picture my example times three. I'm happy to make them "wider" and "shorter" by manipulating the subtables, but that means they become too wide, that's why I thought resizing wouldn't be a bad idea.
    – Morpheu5
    Dec 10 '17 at 17:26
  • @Morpheu5 - Note that I've placed a \small directive right after \label; its scope is the remainder of the current environment (which happens to be the table environment). For sure, it's not necessary to issue a \small directive for each and every cell. If your tables tend to be long rather than wide, you should explore the longtable environment. (As you've no doubt discovered by now, table environments cannot span more than 1 page.)
    – Mico
    Dec 10 '17 at 17:34
  • 1
    I feel deeply honored ;-)
    – user31729
    Dec 10 '17 at 17:46
  • Mmmh, I don't know why placing a \small right after \begin{table}[tb] didn't work. I moved it to right before the first subcaptionbox et voilà. Anyway, as it turns out, none of these help very much in my case, as I can give at most one or two lines back to the main text. The problem is that these tables fit in a page, so no need to use longtable, but they do take up most of the page anyway, so you get only a few lines of body text either above or below a giant table. I might consider placing them in a page of their own, but for some reason they always end up at the end of the document.
    – Morpheu5
    Dec 10 '17 at 17:56
  • 1
    @Morpheu5 - It might be worth your time to post a new query, in which you provide some code examples that are closer to tables you are actually trying to typeset. Do be sure to provide some information about the actual size of the text block and the font and main font size in use in your document.
    – Mico
    Dec 10 '17 at 19:16

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.