13

Context: I've been a casual LaTeX user for years. I've never done a deep tech dive on the platform, but it's always one of those temping "wow I could get lost for years here if I made this my special interest" topics that tempts me. I say all that to say I'm asking from a place of genuine curiosity and not a griping place.

Why can't LaTeX documents support arbitrary text sizes? Is this a cultural thing, or a technical thing, or both?

When I said "can't support arbitrary text sizes", I mean things like this sections of the memoir class documentation

The type size option sets the default font size throughout the document. The class offers a wider range of type sizes than usual. These are:

9pt for 9pt as the normal type size 10pt for 10pt as the normal type size 11pt for 11pt as the normal type size 12pt for 12pt as the normal type size 14pt for 14pt as the normal type size1 17pt for 17pt as the normal type size

My naive assumption would be that "LaTeX is a system that has an algorithm for laying out text", which means "I can layout text at any size". However, when using the memoir class I can't set a 13pt size, a 15pt size, or a 16pt size.

Is this the creators of the memoir class making a decision to only allow certain text sizes? Or are there technical limitations the prevent LaTeX's engine from rendering fonts at arbitrary sizes?

4
  • 3
    well at some time there were limitations - not so much on the technical side but regarding resources like disk space and memory. Nowadays it doesn't matter anymore, and fonts are scalable anyway so one can implement that and e.g. the KOMA classes e.g. contain code to choose arbitrary font sizes. Commented Jun 29 at 23:14
  • 4
    note that with memoir or the standard article you can, given a suitable font, (almost all fonts by default or with computer modern add fix-cm package) have a font of any size so if you want \fontsize{2cm}{2in}\selectfont for letters 2cm high on baselines 2in apart you can, but class options are not so much about the font if you choose 12pt it does set the default size to 12, but more importantly it selects sizes for spaces around math and around lists, and sizes and spaces for section headings in most classes these are a human choice of the designer not just calculated Commented Jun 30 at 0:27
  • 1
  • 1
    LaTex does not print just text but includes Metafont and picture placement aligned with the text. At some point one must scale the pictures (either in some pixel format or in vector formats) with the text, and this can only be done if there is some measure of ratios of these scales. (Similar context: hyphenation also depends on the font size relative to page widths etc) Commented Jul 2 at 9:27

3 Answers 3

22

The original TeX fonts aren’t just scaled up or down. They’re redesigned at each size. Here we see Computer Modern at 6pt and 12pt, scaled to the same height:

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\resizebox{!}{1cm}{\fontsize{6pt}{8pt}\selectfont h}
\resizebox{!}{1cm}{\fontsize{12pt}{14pt}\selectfont h}
\end{document}

Computer Modern font sample

In addition, TeX originally rasterized fonts as bitmaps from METAFONT source files, at whatever DPI you printed your documents at, so a large number of font sizes would have used up a lot of disk space to store bitmaps.

20

Memoir now offers additional sizes. From memoir.cls:

\DeclareOption{9pt}{\renewcommand*{\@ptsize}{9}\renewcommand*{\@memptsize}{9}}
\DeclareOption{10pt}{\renewcommand*{\@ptsize}{0}\renewcommand*{\@memptsize}{10}}
\DeclareOption{11pt}{\renewcommand*{\@ptsize}{1}\renewcommand*{\@memptsize}{11}}
\DeclareOption{12pt}{\renewcommand*{\@ptsize}{2}\renewcommand*{\@memptsize}{12}}
\DeclareOption{14pt}{\renewcommand*{\@ptsize}{4}\renewcommand*{\@memptsize}{14}}
\DeclareOption{17pt}{\renewcommand*{\@ptsize}{7}\renewcommand*{\@memptsize}{17}}
\DeclareOption{20pt}{\renewcommand*{\@ptsize}{20}\renewcommand*{\@memptsize}{20}}
\DeclareOption{25pt}{\renewcommand*{\@ptsize}{25}\renewcommand*{\@memptsize}{25}}
\DeclareOption{30pt}{\renewcommand*{\@ptsize}{30}\renewcommand*{\@memptsize}{30}}
\DeclareOption{36pt}{\renewcommand*{\@ptsize}{36}\renewcommand*{\@memptsize}{36}}
\DeclareOption{48pt}{\renewcommand*{\@ptsize}{48}\renewcommand*{\@memptsize}{48}}
\DeclareOption{60pt}{\renewcommand*{\@ptsize}{60}\renewcommand*{\@memptsize}{60}}

As David said, each of these options does more than simply change the default font size. Each size option corresponds to a file mem\@ptsize.clo which is part of the Memoir package. Since each option requires a supporting file of this kind, the range of sizes supported must be limited.

For example, mem12.clo is 88 lines of code (excluding those beginning with % but I didn't remove any blank lines).

What does this code do? One thing it does is configure the various standard LaTeX size commands: \normalsize, \small, \footnotesize, \tiny, \large, \LARGE and so on. This isn't just a matter of scaling the font, but most importantly the spacing. You do not want the same space between two lines of normally sized font as you do between two lines of \Huge or \tiny. The same goes for all the other spacing LaTeX uses when laying out such things as lists, floats, paragraphs, section headings etc.

\renewcommand{\normalsize}{%
\@setfontsize\normalsize\@xiipt{14.5}%
\abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
\belowdisplayskip \abovedisplayskip
\let\@listi\@listI}
\normalsize
\ifx\MakeRobust\@undefined \else
\MakeRobust\normalsize
\fi

Some of the additional size commands are quite simple, such as \large:

\DeclareRobustCommand{\large}{\@setfontsize\large\@xivpt{18}}

but others such as \small are more elaborate:

\DeclareRobustCommand{\small}{%
\@setfontsize\small\@xipt{13.6}%
\abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
\def\@listi{\leftmargin\leftmargini
\topsep 9\p@ \@plus3\p@ \@minus5\p@
\parsep 4.5\p@ \@plus2\p@ \@minus\p@
\itemsep \parsep
%%               \itemindent\z@
}%
\belowdisplayskip \abovedisplayskip
}

Memoir also supports some size commands not provided by the standard classes, so we also find \miniscule, for example:

\DeclareRobustCommand{\miniscule}{\@setfontsize\miniscule\@viipt{8}}

and it optionally provides \Huge and \HUGE, as well as \huge.

In addition, the size files set up some non-standard sizes such as

\setlength{\onelineskip}{14.5\p@}

and configure some horizontal spaces according to document layout. For example, paragraph indentation is made smaller in two column documents.

\if@twocolumn
\setlength\parindent{1em}
\else
\setlength\parindent{1.5em}
\fi

The standard skips and dimensions must also be defined. For example, we find skips such as

\setlength\smallskipamount{3\p@ \@plus 1\p@ \@minus 1\p@}

For floats alone we have a substantial set of definitions:

\setlength\floatsep    {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\textfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\intextsep   {14\p@ \@plus 4\p@ \@minus 4\p@}
\setlength\dblfloatsep    {14\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\dbltextfloatsep{20\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\@fptop{0\p@ \@plus 1fil}
\setlength\@fpsep{10\p@ \@plus 2fil}
\setlength\@fpbot{0\p@ \@plus 1fil}
\setlength\@dblfptop{0\p@ \@plus 1fil}
\setlength\@dblfpsep{10\p@ \@plus 2fil}
\setlength\@dblfpbot{0\p@ \@plus 1fil}

Good results depend on adjusting all of these settings according to the size of the font by hand, because you do not want to simply multiply everything by a fixed factor. For example, you can't just double (or halve) the distance between the header and the text block if you double (or halve) the font size. A fixed factor won't give good results. Typically, you'll need proportionately more or less space between the lines of text when the font size increases or decreases to avoid things getting too cluttered or too sparse.

So compare the definitions of \normalsize for the 60pt and 9pt options

\renewcommand{\normalsize}{%
\@setfontsize\normalsize\@lxpt{72}% 60pt
\@setfontsize\normalsize\@ixpt\@xpt % 9pt

This shows the distance between the baselines of text is 72pt when 60pt font is used, but 10pt when 9pt is chosen. If 10pt was simply scaled up proportionately, we'd get a distance of 67pt rather than 72pt for 60pt.

\abovedisplayskip 60\p@ \@plus10\p@ \@minus14\p@ % 60
\abovedisplayskip 9\p@ \@plus 2\p@ \@minus 4.5\p@ % 9

This specifies a vertical space typically inserted before a 'display', which needs to be set apart from the main text. The first element is exactly proportionate to the font size, but both the second and third are greater for 60pt than for 9pt. This means that the actual space LaTeX can insert can be altered more in the case of 60pt: it can be expanded or contracted to a greater extent than is allowed for 9pt.

\abovedisplayshortskip \z@ \@plus10\p@ % 60
\belowdisplayshortskip 36\p@ \@plus18\p@ \@minus9\p@ % 60
\abovedisplayshortskip \z@ \@plus 3\p@ % 9 
\belowdisplayshortskip 5.5\p@ \@plus 2.5\p@ \@minus 3\p@ % 9

We see the same for these 'short' skips, too.

So while LaTeX supports arbitrary font sizes and there is absolutely nothing to stop you using whatever size(s) you want in your documents, classes will not necessarily offer to configure arbitrary font sizes for you. The author of Memoir provides a range of choices. If you need or wish for something else, you may define your own or choose a different class.

The important thing to understand here is that this is not a limitation of LaTeX. It is a design choice by the authors of particular classes, including the standard classes (book etc.) and contributed classes (such as memoir).

Any algorithmic solution to this kind of configuration problem would be liable to give sub-optimal results for some font sizes. Note that I do not know if this is why Memoir's designer has chosen not to provide such an algorithm, so the motivation might be entirely different. I merely suggest it as one possible reason that some class designer might reject an algorithmic solution.

3
  • 1
    Sometime back I tried to do this algorithmically, say font sizes can progress based on a harmonic series or some other series, like Pythagoras music. The problem as you pointed out is all the ancillary items like spacing, skips, lists etc. So the algorithm has to deal with a lot of variables. Some of the mathematicians here, that are good with linear algebra might be able to device such a scheme. or schemes. :)
    – yannisl
    Commented Jun 30 at 6:24
  • 1
    @yannisl Possibly. I suspect any algorithm (which could be realistically implemented in this context) would be sub-optimal in some cases. On the other hand, even hand-chosen settings may be sub-optimal for some fonts because there's no standard pt for fonts, as I understand it (it isn't like the printers' measure) and it probably also depends on the style. A font with very short ascenders and descenders likely ideally gets bigger baselineskip, for example, than one with very large ones. Maybe?
    – cfr
    Commented Jun 30 at 6:34
  • Yes true, like many other things one has to provide some inputs to enable a solution. The closest thing to such an algorithm (only for headings and normal text) is what many web designers use. They use ems instead of points so the text can change size as you resize your screen, say from a phone to a large screen on a desktop.
    – yannisl
    Commented Jun 30 at 6:40
2

9pt for 9pt as the normal type size 10pt for 10pt as the normal type size 11pt for 11pt as the normal type size 12pt for 12pt as the normal type size 14pt for 14pt as the normal type size1 17pt for 17pt as the normal type size

I feel there might be some historical reasons as well behind choosing these exact numbers, like it might be the standard sizes used by typesetters in hot metal printing.

3
  • 7
    This seems more a comment than an answer Commented Jun 30 at 8:12
  • I would've loved to post it as a comment but unfortunately I don't have that privilege yet. Thanks for the heads-up anyway, will be mindful about it next time. Commented Jul 6 at 11:20
  • yes well the idea of that is to make you wait until you have a slightly higher rep, not that you post non answers as answers. Commented Jul 6 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .