# Change font inside document to specific point size

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}

-
Should the tables be inside floating environments? If so, should captions associated with the tables also be typeset at 9pt? – Mico Nov 19 '13 at 13:20
@Mico Yes & no. See update. – Sverre Nov 19 '13 at 13:34

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}


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}


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}


-
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

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}

-