[Tex/LaTex] Appearance of \tiny or \scriptsize Fontsize in LaTeX (horizontal stretch)

fontsfontsizegraphicsletterspacing

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:
Ugly stretching of \tiny text in LaTeX

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)

Best Answer

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}

enter image description here

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}}
\newcommand\adapt[1]{%
  \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}
}
\adapt{tiny}\adapt{scriptsize}\adapt{footnotesize}\adapt{small}\adapt{normalsize}
\adapt{large}\adapt{Large}\adapt{LARGE}\adapt{huge}\adapt{Huge}
\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}

enter image description here