[Tex/LaTex] n equivalent to fontspec’s Scale=MatchUppercase for pdflatex? Or how to find out the best scale for two fonts

fontsfontsizescaling

I am using XCharter and tgheroes. Although I do not use the sans in running text, I'd like to scale it accordingly.

Is there any other way than just to do some T&E with the settings? Fontspec's options are really handy in that regard (the ones I know, at least).

I think what the issue is actually based on… which measure does the scale-option for TeX Gyre Heros scale?

("spoiler": the best value for the code below seems to be 0.9)

Picture of MWE output

enter image description here

MWE

\documentclass[
fontsize=12pt,
]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\KOMAoptions{fontsize=11pt}

\usepackage{amsmath}
\usepackage{sansmath}
%
\usepackage[scale=0.96]{tgheros}
\usepackage{tgheros}
\usepackage[bitstream-charter,expert]{mathdesign}
\usepackage[sups]{XCharter}
\usepackage{beramono}

\begin{document}
\begin{center}
\begin{tabular}{rl}
\verb+AAaa\textsf{aaAA}AA+ & AAaa\textsf{aaAA}AA\\
\bfseries\verb+AAaa\textsf{aaAA}AA+ & \bfseries AAaa\textsf{aaAA}AA\\
\verb+XXxx\textsf{xxXX}XXxx+ & XXxx\textsf{xxXX}XXxx\\
\bfseries \verb+XXxx\textsf{xxXX}XXxx+ & \bfseries XXxx\textsf{xxXX}XXxx\\
\end{tabular}
\end{center}
Something else:
\begin{equation}
\sum_{x=3}^{12} \sin(x) \cdot \pi
\end{equation}
\end{document}}

Best Answer

In general this is quite difficult to attain, because each font package has different ideas; for instance, some packages have the scale options, others have scaled, most have neither.

In your case you're lucky, because both tgheros and beramono support scaling, the former with scale, the latter with scaled.

The simplest way is to prepare a document such as

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\KOMAoptions{fontsize=11pt}

\usepackage[bitstream-charter,expert]{mathdesign}
\expandafter\let\csname T1+fvm\endcsname\relax
\usepackage[sups]{XCharter}
\usepackage{beramono}
\usepackage{tgheros}


\begin{document}
\sbox0{A}Charter: \the\ht0

\sbox0{\ttfamily A}Beramono: \the\ht0

\sbox0{\sffamily A}heros: \the\ht0
\end{document}

You get

enter image description here

Now you know that Beramono and TeX Gyre Heros have to be scaled down. How much? Use a pocket calculator:

7.40767/8.17964 ≈ 0.9056
7.40767/8.10298 ≈ 0.9142

so you can do your scaling:

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\KOMAoptions{fontsize=11pt}

\usepackage{amsmath}
\usepackage{sansmath}
%

\usepackage[bitstream-charter,expert]{mathdesign}
\expandafter\let\csname T1+fvm\endcsname\relax
\usepackage[sups]{XCharter}
\usepackage[scaled=0.9056]{beramono}
\usepackage[scale=0.9142]{tgheros}


\begin{document}
\begin{center}
A{\ttfamily A}\\
\begin{tabular}{rl}
\verb+AAaa\textsf{aaAA}AA+ & AAaa\textsf{aaAA}AA\\
\bfseries\verb+AAaa\textsf{aaAA}AA+ & \bfseries AAaa\textsf{aaAA}AA\\
\verb+XXxx\textsf{xxXX}XXxx+ & XXxx\textsf{xxXX}XXxx\\
\bfseries \verb+XXxx\textsf{xxXX}XXxx+ & \bfseries XXxx\textsf{xxXX}XXxx\\
\end{tabular}
\end{center}
\end{document}

enter image description here


Why the strange \expandafter\let\csname T1+fvm\endcsname\relax?

The mathdesign package has its own ideas about what's the right scaling of Bera Mono. That instruction makes LaTeX think it doesn't.