Appearance of \tiny or \scriptsize Fontsize in LaTeX (horizontal stretch)

The fontsize commands for fontsizes smaller than \normalsize stretch the aspect ratio of the letters or stretch the letters itself plus their spacing instead of properly scaling the text in width and height (with respect to \normalsize) - an effect that becomes really extreme for \scriptsize and especially \tiny.

The following minimal example shows the basic problem and a possible solution/workaround to it (to which I need an improved, global turn on / turn off - solution):

 \documentclass[12pt,a4paper,ngerman]{scrbook}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,amsxtra}
\usepackage[ngerman]{babel}
\usepackage{graphicx}

\newcommand{\tinyb}[1]{\scalebox{0.5}{{\normalsize #1}}}
%\newcommand{\scriptsizeb}[1]{\scalebox{0.66667}{{\normalsize #1}}}

\begin{document}
\begin{itemize}
\item {\tiny{Tiny tiny Tiny TINY tiny (original \textbackslash tiny)}} \hspace{.2cm} {\tinyb{Tiny tiny Tiny TINY tiny (custom \textbackslash tinyb)}}
\item {\tinyb{Tiny tiny Tiny TINY tiny (custom \textbackslash tinyb)}}
\item {\normalsize{Tiny tiny Tiny TINY tiny (original \textbackslash normalsize)}}
\item {\tiny{$U_{\infty}=f\cdot a\cdot \frac{\alpha}{\beta}$ (original \textbackslash tiny)}} \hspace{.2cm} {\tinyb{$U_{\infty}=f\cdot a\cdot \frac{\alpha}{\beta}$ (custom \textbackslash tinyb)}}
\item {\tinyb{$U_{\infty}=f\cdot a\cdot \frac{\alpha}{\beta}$ (custom \textbackslash tinyb)}}
%\item {\scriptsize{Scriptsize SCRIPTSIZE (original \textbackslash scriptsize)}} \hspace{.2cm} {\scriptsizeb{Scriptsize SCRIPTSIZE (custom \textbackslash scriptsizeb)}}
%\item {\scriptsizeb{Scriptsize SCRIPTSIZE (custom \textbackslash scriptsizeb)}}
\end{itemize}
\end{document}


The result will look like this:

You will notice that the original \tiny stretches the textwidth extremly, while the workaround with \tinyb uses the scalebox command from the graphicx-package and scales both - height and width of the text - exactly by 50 percent. The fontheight of both styles (\tiny and \tinyb) are exactly identical. Especially in the equation \tiny looks pretty ugly stretched, which is a big problem in small figure's legends or annotations, where only very few letters fit into the legend, even when using \tiny.

The solution with \tinyb (scalebox trick) isn't sufficient for me because I won't be able to change settings globally. I can only change a certain textpattern to \tinyb locally and things like line breaks etc. won't work. It is not a turn on / turn off solution like \tiny or \normalsize, which is what I want: For example I want to use tikzfigures / pgfplots and change the annotation style of all axis legend entries, ticks and graph annotations to \tinyb with only one command but as \tinyb uses a scalebox (which uses a \mbox) I can only use it in specific command lines and code like

\begin{tikzpicture}
\tinyb
\begin{axis}[...
...
xlabel={frequency (Hz) $U_{\infty}$ $\frac{\alpha}{\beta}$},
ylabel={frequency (Hz) $U_{\infty}$ $\frac{\alpha}{\beta}$},
...
\end{axis}
\end{tikzpicture}


won't work (while the same code with \tiny instead of \tinyb would work and change every annotation, label, ticklabel etc. to \tiny)! So I need to redefine \tiny in a way that it behaves like \tinyb or create a newcommand \tinyc that behaves like \tiny but looks like \tinyb. But I could't find out how to change the streching behaviour for different fontsizes. Basically I want that LaTeX properly scales the text in width and height as it would look for \normalsize - specificly for the \tiny and \scriptsize command because the stretching effect is extreme there... and I need a command for that, which must be defined globally and can be set on and off easily for whole sections.

Does anyone know how to do it?

I guess there must be an easy solution, maybe with some packages that allow changing of letterspacing and/or kerning but I actually don't know the right search term for the problem that the letters seem to be stretched with respect to their width... (neither letterspacing nor kerning seem to fit to the problem)

• latex fontsize commands typically don't stretch at all, or if they do they stretch uniformly. For some font families (including computer modern and latin modern) the font designer has provided the font at several design sizes so the small fonts are not scaled versions of the large ones, but glyphs designed to be read at a small size. – David Carlisle Sep 6 '16 at 12:32
• note the font size commands do not take an argument, the usage should be \tiny abc not \tiny{abc} – David Carlisle Sep 6 '16 at 12:35
• I think the very premise of your posting -- "The fontsize commands for fontsizes smaller than \normalsize stretch the aspect ratio of the letters or stretch the letters itself plus their spacing instead of properly scaling the text in width and height (with respect to \normalsize)" [emphasis added] is wrong -- at least for Computer Modern fonts, which are optically rather than mechanically sized. Optical sizing is not "stretching letters plus their spacing". – Mico Sep 6 '16 at 14:14
• @DavidCarlisle and @Mico : Thanks for explaining these aspects to me. I am now aware that the behaviour of \tiny is absolutly intended and probably very useful (for legibility). Anyway I am looking for a solution as I can live with the tradeoff to use a less legible tiny font (as shown in my example with \tinyb) in order to be able to annotate legends properly (needing enough horizontal space for that...), especially while knowing that most documents are read as pdf on a large, high res. screens with +177% or even more in pdf zoom... and one click or touch to zoom even more in detail... – phw Sep 7 '16 at 11:57

Perhaps something like this, with the use of \DeclareFontShape, to tell LaTeX to always use the the 10pt font to construct everything else.

EDITED to employ the otherwise unused "bold-scshape" as the placeholder for the fixed-width version of the font (which is invoked in the tinyb environment).

RE-EDITED to make math font of fixed shape in tinyb environment. Originally, it substituted the fixed shape operators in non-tinyb math, as well. THis was remedied by declaring a new math version to be invoked in the tinyb environment only.

Shown for LMODERN (a scalable T1 encoded font)

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{lmodern}
%%% TEXT FONT FIX
\rmfamily
\DeclareFontShape{T1}{lmr}{bx}{sc}{<-> cmr10}{}% USE BOLD SCSHAPE NOT OTHERWISE DEFINED
%%% MATH FONT FIX
\DeclareFontFamily{OML}{zlmm}{}
\DeclareFontShape{OML}{zlmm}{m}{it}{<-> lmmi10}{}
\DeclareFontShape{OML}{zlmm}{b}{it}{<->ssub * zlmm/m/it}{}
\DeclareFontShape{OML}{zlmm}{bx}{it}{<->ssub * zlmm/m/it}{}

\DeclareMathVersion{Tinyb}
\SetSymbolFont{operators}{Tinyb}{T1}{lmr}{bx}{sc}
\SetSymbolFont{letters}{Tinyb}{OML}{zlmm}{m}{it}
%%%
\newenvironment{tinyb}{\bgroup\tiny\bfseries\scshape\mathversion{Tinyb}}{\egroup} % edit: now with \tiny included
\begin{document}
\newcommand\mytext[1]{\normalsize This is a test #1\par
\small \scalebox{1.11}{This is a test} This is a test \par
\footnotesize \scalebox{1.25}{This is a test} This is a test \par
\scriptsize \scalebox{1.425}{This is a test} This is a test \par
\tiny \scalebox{2}{This is a test} This is a test\par\normalsize
}
\newcommand\mymath{\normalsize$y = mx + b - 3f^2 + \sin (\omega x - \tau)$\par
\tiny$y = mx + b - 3f^2 + \sin (\omega x - \tau)$\par\normalsize}

\mytext{of the normal}

\begin{tinyb}
\mytext{of the fixed scale}
\end{tinyb}

\mymath

\begin{tinyb}
\mymath
\end{tinyb}
\end{document}


The OP seems very much to not want to use a tinyb environment, but rather a \tinyb macro. Here is a possibility that suffers one shortcoming...and that is any font size changing command will place the font in \mdseries\upshape mode, as well.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{lmodern}
%%% TEXT FONT FIX
\rmfamily
\DeclareFontShape{T1}{lmr}{bx}{sc}{<-> cmr10}{}% USE BOLD SCSHAPE NOT OTHERWISE DEFINED
%%% MATH FONT FIX
\DeclareFontFamily{OML}{zlmm}{}
\DeclareFontShape{OML}{zlmm}{m}{it}{<-> lmmi10}{}
\DeclareFontShape{OML}{zlmm}{b}{it}{<->ssub * zlmm/m/it}{}
\DeclareFontShape{OML}{zlmm}{bx}{it}{<->ssub * zlmm/m/it}{}

\DeclareMathVersion{Tinyb}
\SetSymbolFont{operators}{Tinyb}{T1}{lmr}{bx}{sc}
\SetSymbolFont{letters}{Tinyb}{OML}{zlmm}{m}{it}
%%%
\def\invokemode{\bfseries\scshape\mathversion{Tinyb}}
\def\restoremode{\mdseries\upshape\mathversion{normal}}
\expandafter\let\csname sv#1\expandafter\endcsname\csname#1\endcsname%
\expandafter\def\csname#1\endcsname{\restoremode\csname sv#1\endcsname}
\expandafter\def\csname#1b\endcsname{\invokemode\csname sv#1\endcsname}
}
\begin{document}
\tiny Hello World \par
\tinyb Hello World \par
\tiny Hello World \par
\tiny $a^{2} + b^{2} = c^{2}$ \par
\tinyb $a^{2} + b^{2} = c^{2}$ \par
\tiny $a^{2} + b^{2} = c^{2}$
\end{document}


• Is it possible to alter the command that only \tiny and \scriptsize are based on lmr12 and that it also works in math mode - as it is not a bad thing that there is an individual redrawn font for each fontsize in general (especially for prose text!). But in my specific case (\tiny and \scriptsize are typically only used for graphic legends and/or annotations and/or labels, which need to be as small as possible with respect to their width, if I want to place more than one or two words/symbols and still be able to see the rest of the graph). – phw Sep 7 '16 at 5:30
• The perfect solution at which I was aiming at in my original post would work in math mode and text mode and would provide alternative commands (e.g. \tinyb or \scriptsizeb) that are usable in an identical way like \tiny or \scriptsize: turn on or turn off until overwritten by another command such as \normalsize, so the specific commands do not have to involve an \mbox or similar. Is that possible somehow? – phw Sep 7 '16 at 5:30
• @phw I have accomplished it for the text font (see edit). I am still contemplating the math font. – Steven B. Segletes Sep 7 '16 at 10:19
• Thanks so far, this goes exactly in the direction I aimed to. But I didn't fully understand your command, especially I am wondering why I am getting warnings about missing fonts, when using your minimal example: LaTeX Font Warning: Font shape T1/lmr/m/n undefined (Font) using T1/cmr/m/n' instead on input line 8. LaTeX Font Warning: Font shape T1/lmr/bx/n undefined (Font) using T1/lmr/m/n instead on input line 17. LaTeX Font Warning: Some font shapes were not available, defaults substituted. – phw Sep 7 '16 at 12:24
• @phw I believe I have a fix for the math issue, as well. – Steven B. Segletes Sep 7 '16 at 15:14

You should look up what "optical sizing" of fonts entails. (Computer Modern is an example of a font family with optically sized letters at various font sizes.) Letters that are sized optically for \tiny are not ordinary letters reduced linearly by 50%, and they are not simply horizontally stretched either. Instead, they are individually re-drawn, with proportionately thicker strokes, and they are spaced more loosely, all so that they remain legible even though they're only half as tall as \normalsize letters. Conversely, optically-sized \huge letters are deliberately drawn with thinner strokes, and they are spaced more tightly, all so that they don't look too "heavy" even though the height of \huge letters is more than twice that of \normalsize.

The following table shows various words typeset at their "native" 10pt size on the left and linearly enlarged or reduced from having been typeset at \tiny, \scriptsize, \footnotesize, etc through \huge sizes. Note that the letters in the resized words look progressively thinner and are spaced more tightly as you move down the right-hand column of the table.

\documentclass{article}
\usepackage{graphicx,lmodern}
\begin{document}
\begin{tabular}{rl}
basic 10pt    & scaled \\
\hline
five    & \scalebox{2}{\tiny five}\\
seven   & \scalebox{1.429}{\scriptsize seven}\\
eight   & \scalebox{1.25}{\footnotesize eight}\\
twelve  & \scalebox{0.833}{\large twelve}\\
fourteen& \scalebox{0.694}{\Large fourteen}\\
twenty  & \scalebox{0.482}{\huge twenty}\\
\end{tabular}
\end{document}


Addendum: Another way to think about what optical scaling does is to superimpose words natively set at \normalsize with the same words, linearly scaled from their optically sized \tiny, \scriptsize, etc through \huge versions. In the following screenshot, the native-\normalsize letters are rendered in black and the rescaled optically sized words are rendered in red. Observe that optical sizing entails (a) changing the widths of the strokes used for various glyphs as well as (b) changing the kerning between letters in word. It's far more sophisticated than performing a horizontal stretch.

\documentclass{article}
\usepackage{lmodern,graphicx,xcolor}
\begin{document}
\obeylines
five\kern-15.6pt\textcolor{red}{\scalebox{2}{\tiny five}}
seven\kern-23.45pt\textcolor{red}{\scalebox{1.429}{\scriptsize seven}}
eight\kern-21.4pt\textcolor{red}{\scalebox{1.25}{\footnotesize eight}}
twelve\kern-27.18pt\textcolor{red}{\scalebox{0.833}{\large twelve}}
fourteen\kern-35.8pt\textcolor{red}{\scalebox{0.694}{\Large fourteen}}
twenty\kern-29.05pt\textcolor{red}{\scalebox{0.482}{\huge twenty}}
\end{document}

• Thank you very much for shedding light on this topic. I already guesses that it is some 'problem' like that. Anyway: in my specific case (\tiny and \scriptsize are typically only used for graphic legends and/or annotations and/or labels, which need to be as small as possible with respect to their width, if I want to place more than one or two words or math symbols and still be able to see the rest of the actual graphs). Is there a solution that would behave exactly like \tiny (and working in math mode) but use a shrinked width, until overwritten by another command such as \normalsize? – phw Sep 7 '16 at 5:43
• @phw - By using either \scriptsize or \tiny for the caption and annotation items, you're already making sure that such items take up a lot less space than they would at \footnotesize, let alone \normalsize. For Computer Modern, the fonts that are selected for \tiny and \scriptsize material are optimized -- after all, that's what optical scaling is all about -- for legibility at those sizes. Any space gains you may achieve by using non-optimized fonts at these sizes will almost certainly be outweighed by a noticeable loss of legibility. In short, do be aware of this trade-off. – Mico Sep 7 '16 at 10:37
• You're right of course. But indeed I want to show several figures with graphs (e.g. side by side figures), which have individual legends. And the space available for the text in the legend is really really short, even when using \footnotesize. I noticed that the gain of "width" when using \tiny compared to \footnotesize is not that much, as tiny really looks stretched in width (for the purpose of legibility, I know). So I am looking for a proper solution as described, anyway - beeing aware of all this; especially beeing aware of high res. screens and the ability to read pdfs at +150%... – phw Sep 7 '16 at 11:46
• @phw - If space for the captions and legends is truly so limited in your document, your first priority should be to make the captions and legends more concise, say, by omitting all material that's not absolutely essential. Remember the saying from Hamlet, "Brevity is the soul of wit." Be brief, and write down only what absolutely needs to be expressed, rather than find a suboptimal scaling of fonts... Your readers will be most grateful for this act of kindness. – Mico Sep 7 '16 at 13:31

As has been explained in comments and other answers, it is not latex that is scaling the fonts, it is just choosing the fonts designed for that size.

If you do not like the font choice you can change it here I specify that the 10pt font is to be used scaled for all sizes (I just did roman and math italic, you may need to do more) In general such scaling is considered to make a poorer less legible result than using optically scaled fonts at their design size, but all these things are a subjective choice.

\documentclass[12pt,a4paper,ngerman]{scrbook}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,amsxtra}
\usepackage[ngerman]{babel}
\usepackage{graphicx}

\newcommand{\tinyb}[1]{\scalebox{0.5}{{\normalsize #1}}}
%\newcommand{\scriptsizeb}[1]{\scalebox{0.66667}{{\normalsize #1}}}
\DeclareFontFamily{T1}{lmr}{}
\DeclareFontShape{T1}{lmr}{m}{n}%
{<->    ec-lmr10
}{}

\DeclareFontFamily{OML}{lmm}{\skewchar\font127 }
\DeclareFontShape{OML}{lmm}{m}{it}%
{<->  lmmi10
}{}

\begin{document}
\begin{itemize}
\item {\tiny Tiny tiny Tiny TINY tiny (original \textbackslash tiny)} \hspace{.2cm} {\tinyb{Tiny tiny Tiny TINY tiny (custom \textbackslash tinyb)}}
\item {\tinyb{Tiny tiny Tiny TINY tiny (custom \textbackslash tinyb)}}
\item {\normalsize Tiny tiny Tiny TINY tiny (original \textbackslash normalsize)}
\item {\tiny{$U_{\infty}=f\cdot a\cdot \frac{\alpha}{\beta}$ (original \textbackslash tiny)}} \hspace{.2cm} {\tinyb{$U_{\infty}=f\cdot a\cdot \frac{\alpha}{\beta}$ (custom \textbackslash tinyb)}}
\item {\tinyb{$U_{\infty}=f\cdot a\cdot \frac{\alpha}{\beta}$ (custom \textbackslash tinyb)}}
%\item {\scriptsizeScriptsize SCRIPTSIZE (original \textbackslash scriptsize)} \hspace{.2cm} {\scriptsizeb{Scriptsize SCRIPTSIZE (custom \textbackslash scriptsizeb)}}
%\item {\scriptsizeb{Scriptsize SCRIPTSIZE (custom \textbackslash scriptsizeb)}}
\end{itemize}
\end{document}

• I'm not sure that legibility is exactly subjective. Wouldn't it be better to use a font designed to be one-size-fits-all? While such fonts are not generally considered such high quality, if you don't want that quality, then the compromises the designer makes to allow for scaling (if the font is well-designed) would be an advantage. – cfr Sep 6 '16 at 18:38
• @cfr probably yes, although the code here is more intended of how to get the requested effect without using scalebox rather than a demonstration of something to be recommended in a document, and in general it is not unreasonable to use modified .fd declarations to get different choices in fonts at certain sizes, even if the extreme of using 10pt font everywhere is not used. – David Carlisle Sep 6 '16 at 18:51
• Indeed, I think it can sometimes work well and be quite reasonable. I just find 10pt Latin Modern scaled to \tiny almost illegible. After all, it was really not designed for that! – cfr Sep 6 '16 at 19:16
• Thanks for your response. The solution at which I was aiming at in my original post would work in math mode and text mode and provide alternative commands (e.g. \tinyb or \scriptsizeb) that are usable in an identical way like \tiny or \scriptsize: turn on or turn off until overwritten by another command such as \normalsize, so the specific commands are not allowed to involve an \mbox or similar. Is that possible somehow? The provided solution is the same like in my own example, right?: I would have to use \tinybwith brackets {}, in which only the command affected the fontsize. – phw Sep 7 '16 at 5:34
• @phw you can not use size change commands in math mode, but if you use math at the small size, it is affected. Yes of course you could define a new font family lmr2 say instead of lmr and then just copy the lm fd files, to lm2 fd files, changing the definitions as you go, then just switch via \fontfamily{lmr2}\selectfont – David Carlisle Sep 7 '16 at 7:47