5

I have noticed that when using the command \scalefont{} (from the scalefnt package), a decrease in the scaling factor does not always produce a corresponding decrease in the displayed font size.

To illustrate, consider

\documentclass{book}
\textwidth=5.76in
\usepackage{scalefnt}
\usepackage{lipsum}
\usepackage{xcolor}

\begin{document}
\thispagestyle{empty}
\parindent 0pt
\large

\textcolor{red}{\LARGE{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}
\textcolor{red}{\LARGE{\scalefont{0.99}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}
\textcolor{red}{\LARGE{\scalefont{0.98}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}
\textcolor{red}{\LARGE{\scalefont{0.97}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}
\textcolor{red}{\LARGE{\scalefont{0.96}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}
\textcolor{red}{\LARGE{\scalefont{0.95}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}
\textcolor{red}{\LARGE{\scalefont{0.94}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}
\textcolor{red}{\LARGE{\scalefont{0.93}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}
\textcolor{red}{\LARGE{\scalefont{0.92}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}
\\[3pt]
\textcolor{red}{\LARGE{\scalefont{0.91}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION \textcolor{black}{(0.91)}}}}}
\\[8pt]
\lipsum[13]
\end{document}

the output of which is

enter image description here

The textwidth is set at 5.76in and the first red title in the output had no scaling applied to it.

The scaling factors applied to the second thru the eighth titles are 0.99, 0.98, 0.97, 0.96, 0.95, 0.94, 0.93, and 0.92, respectively.

But, upon inspecting the output, it appears that no actual scaling had taken place until the tenth title---which is associated with a scaling factor of 0.91.

QUESTION: What is (might be) causing this anomaly between the scaling factor and the actual output, which, by the MWE, seems likely to be a frequent occurrence? Is there a way to correct this phenomenon so that change in the scaling factor always produces some effect---for as one can see, a big difference occurs when the font size is finally decreased, while the gradual ones that one would expect along the way, seem to be presently unattainable?

Thank you.

2 Answers 2

6

Note LaTeX does warn you. Each font size selection produces a warning such as

LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <15.89755> not available
(Font)              size <17.28> substituted on input line 20.

and at the end of the run

LaTeX Font Warning: Size substitutions with differences
(Font)              up to 1.38245pt have occurred.

Computer Modern is set up to only use a fixed set of sizes to avoid filling your disk with bitmap fonts, even though for the last 25 years or so bitmap fonts have not been used by default, the scalable type1 versions are used, and in any case the bitmaps wouldn't fill your disk.

If you choose more or less any other font set it will scale as specified so

\usepackage{lmodern}

to use the Latin Modern variant or if you want Computer Modern scaled naturally add

\RequirePackage{fix-cm}

at the start of the document.

Unrelated, but note \Large does not take an argument so use \Large ... not \Large{...} and include the end of paragraph in its scope to get a suitably large baselineskip (which is why the large text in your image is not spaced on a suitable baseline)

4

What is causing the problem: a) the font must be scalable b) you need to separate each line with a \par. As TeX will treat all the lines as one paragraph, and apply the font sizing once. If you can use LuaLaTeX, it gives you so many more options using the fontspec package.

% run with LuaLaTeX or pdfLaTeX
\documentclass{book}
\textwidth=5.76in
\usepackage{scalefnt}
\usepackage{xcolor}
\ifdefined\directlua
\usepackage{fontspec}
  \setmainfont{texgyrepagella-regular.otf}[
     BoldFont = texgyrepagella-bold.otf ,
     ItalicFont = texgyrepagella-italic.otf ,
     BoldItalicFont = texgyrepagella-bolditalic.otf ]
\else
  \usepackage{mathpazo}
\fi
\begin{document}
\thispagestyle{empty}
\parindent 0pt
\large

\textcolor{red}{\LARGE{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}\par
\textcolor{red}{\LARGE{\scalefont{0.99}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}\par
\textcolor{red}{\LARGE{\scalefont{0.98}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}\par
\textcolor{red}{\LARGE{\scalefont{0.97}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}\par
\textcolor{red}{\LARGE{\scalefont{0.96}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}\par
\textcolor{red}{\LARGE{\scalefont{0.95}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}\par
\textcolor{red}{\LARGE{\scalefont{0.94}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}\par
\textcolor{red}{\LARGE{\scalefont{0.93}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}\par
\textcolor{red}{\LARGE{\scalefont{0.92}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}\par
\textcolor{red}{\LARGE{\scalefont{0.91}{\textbf{A TITLE TO ILLUSTRATE AN OBSERVATION}}}}

 \ExplSyntaxOn
  \dim_zero:N \l_tmpa_dim
  \dim_set:Nn \l_tmpa_dim {0.5pt}
  \dim_while_do:nNnn {\l_tmpa_dim} < {13pt} {
       \dim_add:Nn \l_tmpa_dim {1pt}
       \bfseries\fontsize{\l_tmpa_dim}{\l_tmpa_dim*1.2}\selectfont
       Fontsize\par
  }
\ExplSyntaxOff
\end{document}

enter image description here

3
  • It looks like only (a), scalable font, is the problem and (b), use of \par, actually doesn't matter, right? Meaning, with pdflatex, using a scalable font with \usepackage{lmodern} or fix-cm always scales the font properly, with or without \par, and the default Computer Modern never scales the font, with or without \par.
    – Marijn
    Sep 26, 2021 at 11:50
  • Both need to be resolved. If you take the \par's out you will see the first block will form a paragraph and hyphenate. Sep 26, 2021 at 12:33
  • The block will form a paragraph without \par, but each sentence will still be properly scaled (i.e., slightly smaller than the previous sentence), with or without \par, right?
    – Marijn
    Sep 26, 2021 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.