10

Although this question has a duplicate flavor to it, the question that allegedly provides the solution, LaTeX -- specify font point size?, is hard to use since neither the question nor the answer contains a MWE or any code snippet at all to demonstrate the effect. The answer is also according to comments incomplete with respect to the necessary macros to include.

So I'll ask again. I need to set my tables in a 9pt font, whereas the document text should be in a 12pt font, and the document should throughout be double spaced. How?

\documentclass[12pt]{article}
\usepackage{setspace,lipsum}
    \doublespacing
\begin{document}
\lipsum[2]

\begin{tabular}{*3{l}} % <- this table should be set in 9pt
    Word & Word & Word\\
    Word & Word & Word\\
    Word & Word & Word\\
\end{tabular}

\lipsum[2]
\end{document}

I would have thought there was a package for something as fundamental as this?


EDIT

The example above was intended to be as minimal as possible (so that it's helpful to other people who find this question - I am always bothered by finding questions that are so unnecessarily specific and complicated that I'm not able to use it for my own document).

So what I really need this for is for floating tables (the caption should have 12pt as the document text). Below is such a MWE. The output does not, for some reason, have double spacing in the table.

\documentclass[12pt]{article}
\usepackage{setspace,lipsum}
    \doublespacing
\usepackage[justification=centering, font=normalsize, labelfont=bf]{caption}

\begin{document}
\lipsum[2]

\begin{table}
\centering\fontsize{9}{11}\selectfont
\begin{tabular}{*3{l}}
    Word & Word & Word\\
    Word & Word & Word\\
    Word & Word & Word\\
\end{tabular}
\caption{My table}
\end{table}

\lipsum[2]
\end{document}
Moriambar
  • 11,466
Sverre
  • 20,729

2 Answers2

11

Just tell LaTeX to use nine point type.

\documentclass[12pt]{article}
\usepackage{setspace,lipsum}
    \doublespacing
\begin{document}
\lipsum[2]

\begin{center}\setstretch{1}\fontsize{9}{11}\selectfont
\begin{tabular}{*3{l}} % <- this table should be set in 9pt
    Word & Word & Word\\
    Word & Word & Word\\
    Word & Word & Word\\
\end{tabular}
\end{center}

\lipsum[2]
\end{document}

enter image description here

For a really awful result, here's what you want:

\documentclass[12pt]{article}
\usepackage{setspace,lipsum}
    \doublespacing
\begin{document}
\lipsum[2]

{\strut\fontsize{9}{11}\selectfont
\begin{tabular}[t]{*3{l}} % <- this table should be set in 9pt
    Word & Word & Word\\
    Word & Word & Word\\
    Word & Word & Word\\
\end{tabular}}

\strut\lipsum[2]
\end{document}

enter image description here

The fact that in a table environment the interline spacing is reset to single spacing is a precise choice made by the setspace package. You can revert it by removing the setting the package does.

\documentclass[12pt]{article}
\usepackage{setspace,lipsum}
\usepackage[justification=centering, font=normalsize, labelfont=bf]{caption}

\makeatletter
\let\@xfloat\latex@xfloat % remove the redefinition made by setspace
\makeatother

\doublespacing

\begin{document}
\lipsum[2]

\begin{table}
\centering\fontsize{9}{11}\selectfont
\begin{tabular}{*3{l}}
    Word & Word & Word\\
    Word & Word & Word\\
    Word & Word & Word\\
\end{tabular}
\caption{My table}
\end{table}

\lipsum[2]
\end{document}

enter image description here

David Carlisle
  • 757,742
egreg
  • 1,121,712
  • This table does not have double spacing, though. Does this mean that if I change the font size of the table, the spacing set by setspace is disregarded? And what is the \setstretch for? – Sverre Nov 19 '13 at 12:56
  • @Sverre Just remove \setstretch{1} and also the table will be double spaced. I thought you wanted the table single spaced. – egreg Nov 19 '13 at 13:01
  • I'm just curious about these details. According to the question/answer I linked to, the second argument in \fontsize should be 1.2 times greater than the first argument, but 11 is 1.23 times greater than 9. Does that detail not matter? If I used onehalfspacing in my document, would \fontsize{9}{11}\selectfont for my table then also respect that setting and produce 1.5 line spacing? – Sverre Nov 19 '13 at 13:05
  • Also, you answer adds a center environment that I didn't have in my question. When I add \fontsize{9}{11}\selectfont before \begin{tabular}, the rest of the document changes to a smaller point size, and if I add \fontsize{9}{11}\selectfont after \begin{tabular}, only the first cell gets a smaller font size. So how do I do this without adding a center environment? – Sverre Nov 19 '13 at 13:08
  • @Sverre I can't see why you should want a table without some additional spacing before and after it. However, I'll show you how to do it: the document is yours and if it will be awful I take no responsibility. ;-) – egreg Nov 19 '13 at 13:13
  • @Sverre see my version for avoiding the center environment. – Ruben Nov 19 '13 at 13:15
  • @egreg My actual document will not look like my MWE, no worry. The tables I'm gonna do this in will be floats. I'm just trying to obey the M part in "MWE" :). I just think the solution shouldn't add extra code to the MWE unless it is needed to solve the problem at hand, since this could be misinterpreted as being needed to solve the problem (and in my case it confused me, since I didn't know where to add the \fontsize argument). – Sverre Nov 19 '13 at 13:20
  • If the tabular is in a table float, then this should be part of the MWE. Indeed the case is quite different. – egreg Nov 19 '13 at 13:21
  • @egreg I see. Mico's comment, I think, reflects what you say. Btw, what does \strut do? I see no difference in the table when I don't include it. – Sverre Nov 19 '13 at 13:23
  • @Sverre I see a big difference if I don't include both \strut commands; actually the first one is not really needed, but the second is. – egreg Nov 19 '13 at 13:26
  • @egreg I didn't even see the second one ... – Sverre Nov 19 '13 at 13:27
  • @egreg Cf. my updated question. – Sverre Nov 19 '13 at 13:35
  • @Sverre I updated my answer – egreg Nov 19 '13 at 14:37
  • In the latter case you can also just add \doublespacing (that way no fiddling with the setspace package is needed): \centering\doublespacing\fontsize{9}{11}\selectfont. – Sverre Nov 20 '13 at 14:15
1

I read the plural form of 'table' in the OP. So, "stealing" @egregs solution I generalized:

\documentclass[12pt]{article}
\usepackage{setspace,lipsum}
  \doublespacing
\usepackage{etoolbox}
\preto\tabular{\fontsize{9}{11}\selectfont}

\begin{document}
%all tables should be set in 9pt now
\lipsum[2]

\medskip
\begin{tabular}{*3{l}}% <- especially this one
    Word & Word & Word\\
    Word & Word & Word\\
    Word & Word & Word\\
\end{tabular}
\medskip

\lipsum[2]
\end{document}
Troy
  • 13,741
Ruben
  • 13,448