0

Consider the following MWE where the first section heading contains letters with ascender and the second does not:

\documentclass{article}
\usepackage{fontspec}

% https://github.com/adobe-fonts/source-serif-pro or
% https://ctan.org/pkg/sourceserifpro
\setmainfont{Source Serif Pro}

\begin{document}
\section*{\rlap{\rule{8.5in}{0.04pt}}bbbbb}
\leavevmode\rlap{\rule{8.5in}{0.04pt}}bbbbb

\newpage

\section*{nnnnn\llap{\rule{8.5in}{0.04pt}}}
nnnnn\llap{\rule{8.5in}{0.04pt}}
\end{document}

Why are the baselines in the two section headings misaligned? I have tried the following tests:

  1. Baselines do align: When set in Computer Modern (without fontspec and under pdfLaTeX), Latin Modern, TeX Gyre Termes, etc.
  2. Baselines do not align: When set in some of the commercial fonts I have.
  3. Baselines do align: With only body text bbbbb and nnnnn (i.e., commenting out the two \section*’s), for all aforementioned fonts, including Source Serif Pro and other commercial fonts.

The third observation really threw me off…

2

The b in Source Serif Pro is larger than the one in latin modern. And more importantly in a section title its height is larger than \topskip. This means that its baseline will be moved down by 0.45pt at the start of the page. If you want to avoid this effect, enlarge \topskip with such fonts.

\documentclass{article}
\usepackage{fontspec}

\begin{document}
\section*{\the\fontcharht\font`\b bbbb}

\setmainfont{Source Serif Pro}
\section*{\the\fontcharht\font`\b bbbb}

\the\topskip
\end{document}

enter image description here

  • Thanks for the pointer. Enlarging \topskip is not a good option for me as it messes up other body-only pages. I decided to \newcommand*\headingstrut{\vrule height\dimexpr\f@size\p@*880/1000 width\z@\relax} and put \headingstrut wherever I could in the class declaration. – Ruixi Zhang Jul 9 at 13:42

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.