The task
I’m writing my thesis in (Xe)LaTeX, using fontspec
for font definitions. The document’s main font size is 12pt
, passed to TeX via a \documentclass
option. I want to define myself an auxiliary font with 10pt
size for certain uses. Ideally, I would want to enter that size of the auxiliary directly when defining it with \newfontfamily
.
Skim ahead to ‘the question’ section for what one could call a ‘too long, didn’t read’ summary.
Potential solutions known to me
One thing I immediately noticed is that \footnotesize
would scale the text to 10pt
— the correct font size that I am looking for. I employed this in two different ways as can be seen later in the MWE.
Another option is to use fontspec
’s SizeFeatures
, as recommended in this answer.
A third one is to define a \fontsize
— however, that requires calculating two different values; something I think TeX should do rather than me.
Finally, one can also Scale
the font in its defintion as this answer recommends.
I did not find any direct ways to specify a font’s size via the \newfontfamily
command in the fontspec
documentation on CTAN.
The MWE
\documentclass[12pt]{report} % see also note [1]
\usepackage{mathspec} % includes fontspec
\usepackage{polyglossia} % for languages — see note [2]
\setmainlanguage[babelshorthands=true,spelling=new]{german}
\usepackage{lipsum}
\setmainfont[Mapping=tex-text]{LiberationSerif} % my main font — see note [3].
\newfontfamily\antiquasans[Mapping=tex-text]{LiberationSans} % A secondary font for demonstration
\newfontfamily\overpicfont[Mapping=tex-text, SizeFeatures={Size=10}]{LiberationSans} % defining with SizeFeatures
\newfontfamily\overpicscale[Mapping=tex-text, Scale=0.83]{LiberationSans} % defining with Scale
\newcommand\overpiccommand[1]{{\antiquasans\footnotesize #1}} % defined as an environment.
\begin{document}
\lipsum[1] % a comparison paragraph
{\antiquasans \lipsum[1]} % a sans-serif paragraph with 12pt
\overpiccommand{\lipsum[1]} % the environment including \footnotesize
{\overpicfont\footnotesize\lipsum[1]} % font forced to 10pt by SizeFeatures and footnotesize
{\overpicfont\lipsum[1]} % font forced to 10pt by SizeFeatures
{\overpicscale\lipsum[1]} % font scaled
\lipsum[1] % 12pt comparison paragraph
\end{document}
Rendered output
The rendered output with a document font size of 12pt
is split into two images as there was a page break.
From top to bottom:
- last line of standard (serif) text
- sans-serif with
\antiquasans
\overpiccommand
environment, includes\antiquasans\footnotesize
\overpicfont\footnotesize
variant — includes bothFontFeatures
and\footnotesize
. This is the paragraph split by a page break.- using only
FontFeatures
- using only
Scale
- comparison text in
12pt
serif typeface.
In the 10pt
document, we can compare the following paragraphs:
- last line of standard (serif) text
- sans-serif with
\antiquasans
\overpiccommand
environment, includes\antiquasans\footnotesize
\overpicfont\footnotesize
variant — includes bothFontFeatures
and\footnotesize
. Note that\footnotesize
defines8pt
here while theFontFeatures
require10pt
.- using only
FontFeatures
Testing results
The first thing that I noticed was that different ways to define 10pt
in a 12pt
document led to two different line heights — see the attached images. The fonts’ (both Liberation’s and LiberationSans’) standard 12pt
line height is c. 5 mm. Using the SizeFeature
forcing and the Scale
factor, the line heights remained this even if the font size was smaller. Anything that included \footnotesize
(the environment and the additional \footnotesize
forcing) gave a line height of c. 4.2 mm consistent with the standard line height of the 10pt
document.
Therefore, using the SizeFeatures
or Scale
options is not an option as it results in incorrect (too large) line spacing.
Further testing with the 10pt
document revealed that SizeFeatures
does not affect line height at all: the paragraph including \footnotesize
and a SizeFeatures
scaled font had a line height of c. 3 mm — consistent with 8pt
footnotes — while the font size was clearly 10pt
as requested by SizeFeatures
.
Conclusions
As I stated before, I don’t want to use
\fontsize
. I want to somehow tell TeX to use a font size of10pt
in my12pt
document and let the engine do the required scaling.For the same reason, I am not happy with using
SizeFeatures
. These make the font size smaller but do not adjust the line height.Using a
Scale
argument also comes with that problem but also the added disadvantage that10/12
is a nonfinite number. So rather than entering a clear10pt
, I have to make do with some approximation. A very bad solution.Using an environment would probably work if I had only inline examples, but I suspect it is going to fail for the intended uses I have. However, given that the environment definition worked, I can most likely define myself a command that would expand to the same thing.
The least-best option is to just append a
\footnotesize
to every occurance of\overpicfont
.
The question
Does some way of adding a discreet, non-variable font size option exist when defining a new font family, such that TeX automatically chooses appealing line heights and adjusts all other sizes accordingly? Something along the lines of:
\newfontfamily\tenpointfont[size=10pt, other options]{MyCrazyFontsName}
Notes
[1]: I also ran a comparison run without the 12pt
option, i.e. with TeX’ standard font size of 10pt
.
[2]: For some reason, I got an error when not including polyglossia
and a language definition, hence I left it in the document. I don’t think it’s crucial in any way, though.
[3]: I have read that Mapping=tex-text
and Ligatures=TeX
are identical while the latter ensures compability with LuaLaTeX. Since I am only using XeLaTeX, I did not change this when copying from my last thesis.
size12.clo
which is loaded by thearticle
class and not by the font. Internally it uses\fontsize
, and specifies both a fontsize and the leading. This is why using the builtin font changing commands work the way they do. So define your font family and then make wrappers which calculate the size correctly using\fontsize
. The leading can be calculated to be whatever proportion of the fontsize you like.\footnotesize
is the correct way.\footnotesize
which selects 10pt font on 12pt baseline in the report class 12pt option.\overpicfont\footnotesize
is the shortest way to do this, then the answer is ‘no, there is no faster and direct way.’\antiquasans\footnotesize
would be the normal way. You can of course define that to be a single command if you need it often.