Friday, June 21, 2013

Changing the font size in LaTeX

This post is from here.


Changing the font size in LaTeX can be done on two levels, either affecting the whole document or parts/elements of it. Using a different font size on a global level will affect all normal-sized text as well as the size of headings, footnotes, etc. By changing the font size locally, however, a single word, a few lines of text, a large table or a heading throughout the document may be modified.

Changing the font size on a document-wide level

The standard classes, article, report and book support 3 different font sizes, 10pt, 11pt, 12pt (by default 10pt). The font size is set through the optional argument, e.g.:

\documentclass[12pt]{report}

In most cases, the available font sizes for the standard classes are sufficient.

Other font sizes

Should you require a different font size for your document, use the extsizes package. It allows for the following font sizes: 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt, 20pt.

The documentclass names are slightly different from the standard classes:

%Article
\documentclass[9pt]{extarticle}
%Report
\documentclass[14pt]{extreport}

The KOMA-script and memoir class

The KOMA-script and memoir classes are more flexible when it comes to font sizes. Please see the documentation for more details.

Changing the font size locally

LaTeX knows several font size modifier-commands (from biggest to smallest):

\Huge
\huge
\LARGE
\Large
\large
\normalsize(default)
\small
\footnotesize
\scriptsize
\tiny

A table of the exact font sizes in points can be found on wikibooks.

A good rule of thumb is don’t use too many different sizes and don’t make things too small/big.

There are two possible ways to use these font size modifier commands, inline or as environment:

% inline
{\LargeThis is some large text\par}

% environment
\begin{footnotesize}
...
\end{footnotesize}

The \par at the end of the inline example adjusts baselineskip, the minimum space between the bottom of two successive lines. See the example in Rob’s comment below.

A few more options

The moresize package adds two more to the list above, \HUGE and \ssmall. The latter fills the gap between \scriptsize and \tiny.

While using \HUGE, LaTeX displays a warning saying the font size is not available for the standard font and that it was replaced by the next smaller (\Huge). When using another font type, such as the Adobe Times Roman equivalent available in the PSNFSS package (see example below), however, you can benefit from that font size.

\documentclass[11pt]{report}
\usepackage{mathptmx}
\usepackage[11pt]{moresize}
...
{\HUGEA huge text}

{\ssmallCan you still read this ``ssmall'' text?}

Note: The figure is scaled and therefore does not show the actual font size. It illustrates the difference between the font sizes.

Still not enough?

Here is alternative, more flexible approach. The anyfontsize package scales the next bigger/smaller font size available to whatever size you like.

The two arguments to \fontsize are the actual font size and the size of the baseline-skip.The baseline-skip should be set to roughly 1.2x the font size.

\fontsize{size}{baselineskip}

The following example shows font size 50pt/5pt and compares them with \Huge and \tiny.

\documentclass[11pt]{report}
\usepackage{mathptmx}
\usepackage{anyfontsize}
\usepackage{t1enc}
...
{\fontsize{50}{60}\selectfontFoo}{\fontsize{5}{6}\selectfontbar!}
{\HugeFoo}{\tinybar!}

That’s more like it! Again, this only works with a non-standard font type. And again, it does not show the actual font size. Try it with LaTeX!

Source with more details: here and there.

No comments:

Post a Comment