# Why does the baseline skip depend on the letters depth in some fonts?

I have some trouble with the line high using an OTF with fontspec package.

The baseline skip of a line differs depending on the depth of the used letter. So for example a line containing a »g« is some points higher than another one containing only letters without a depth.

The screen shot shows the strange behavior: You can easily see that on the second page the first line is a little lower than on the first page. The only difference between both is the lowercase »g« in the title.

The font I am actually using is »Adobe Garamond Pro« but I have tested with other fonts such as »Minion Pro« experiencing the same effect.

However, the effect does not occur without using fontspec. Here is an example, that of course only works were the font is present:

\documentclass[a4paper,10pt,oneside]{memoir}
\usepackage{lipsum}
\usepackage{fontspec, calc}

\begin{document}
\chapter{Test what ever but lon er even lon er much lon er  Test}
\lipsum[2-4]
\chapter{Testing what ever but longer even longer much longer}
\lipsum[2-4]
\end{document}


Can somebody explain to me, what is happening here, dnd give me a hint, how to work around?

• I don't have Garamond Pro, but problem confirmed for another common font, \setmainfont{Palatino Linotype}, using XeLaTeX – Steven B. Segletes Sep 25 at 10:21
• For reference, the problem also arises with \begin{document} \chapter{Test what ever but lon\smash{g}er even lon\smash{g}er much lon\smash{g}er Test} \lipsum[2-4] \chapter{Test what ever but longer even longer much longer Test} \lipsum[2-4] \end{document} – Steven B. Segletes Sep 25 at 10:25
• It would be easier to debug if you could show an example with a generally available font, but I would guess looking at the image that if you add \showoutput you will see \lineskip glue being added. \lineskip is only added when tex has an otherwise infeasible constraint and the material it is adding is already larger than the specified baselineskip, so it gives up trying to maintain an even baseline and just inserts \lineskip between the rows. If that is the case you just need to make the text smaller or the \baselineskip larger, depending... – David Carlisle Sep 25 at 10:37

Taking Steven's modified example, as I have the font, then if you add some debug messages

\documentclass[a4paper,10pt,oneside]{memoir}
\usepackage{lipsum}
\usepackage{fontspec, calc}
\setmainfont{Palatino Linotype}

\begin{document}
\chapter[zz]{Test what ever but lon er even lon er much lon er
Test}

\expandafter\typeout\expandafter{\the\font}
\expandafter\typeout\expandafter{\the\baselineskip}
\expandafter\typeout\expandafter{\the\fontcharht\fontN}
\expandafter\typeout\expandafter{\the\prevdepth}
\expandafter\typeout\expandafter{\the\dimexpr\prevdepth +\fontcharht\fontT\relax}

\lipsum[2-4]
\chapter{Test what ever but longer even longer much longer Test}

\expandafter\typeout\expandafter{\the\font}
\expandafter\typeout\expandafter{\the\baselineskip}
\expandafter\typeout\expandafter{\the\fontcharht\fontN}
\expandafter\typeout\expandafter{\the\prevdepth}
\expandafter\typeout\expandafter{\the\dimexpr\prevdepth +\fontcharht\fontT\relax}

\lipsum[2-4]
\end{document}


Then you get

\TU/PalatinoLinotype(0)/m/n/10
12.0pt
7.1582pt
0.78989pt
7.94809pt
[1]
\TU/PalatinoLinotype(0)/m/n/10
12.0pt
7.1582pt
5.54956pt
12.70776pt
[2]


TeX is being asked to set the first line of the paragraph to a 12pt baselineskip from the baseline of the previous thing. In the first case that means that the actual added \baselineskip glue will be just over 4pt, however in the second case even if the line was abutted directly after the heading there would be 12.7pt baseline separation. In this case TeX does not back up and over-print to force the requested baseline, instead it gives up on \baselineskip and inserts the fixed \lineskip glue that does not depend on the height and depth of the lines it is separating. \lineskip is usually 0pt or 1pt but whatever value it has, if it is added it means that there is inconsistent spacing in the output.

• Thanks for the explanation, I would have never found out by my self. But do you have a suggestion other than increasing the \linespread? Would you agree, that setting lineskiplimit to negative value is an appropriate solution, as suggested here: tug.org/pipermail/xetex/2006-February/003179.html – user5950 Sep 26 at 9:52

Apparently, the font has large descenders (and perhaps also large ascenders).

A small adjustment of the leading will solve the issue. In this example I used Minion Pro, as I don't have Adobe Garamond Pro.

The humoungous setting to \lineskip is meant to show that the parameter doesn't enter into action (if it does, you'd see a very big vertical space).

\documentclass[a4paper,10pt,oneside]{memoir}
\usepackage{lipsum}

\usepackage{fontspec}
\setmainfont{Minion Pro}

\begin{document}

\setlength{\lineskip}{30pt} % just for testing

\chapter{Test what ever but lon er even lon er much lon er  Test}
\lipsum[2-4]
\chapter{Testing what ever but longer even longer much longer}
\lipsum[2-4]

\end{document}


## Without the \linespread adjustment

Here you see the 30pt added space because of \lineskip entering the scene.

• globally increasing the linespacing might be hitting this with an over-sized sledgehammer though, the baselines for large and normalsize are individually large enough to contain their respective fonts, it is just at the handover where you have a large descender followed by a normalsize paragraph you need to account for the depth – David Carlisle Sep 25 at 11:52
• Good explanation, but with Adobe Garamond Pro this would mean one has to set linespread to 1.07, what is not desirable for a book. The long highs and deep depth are actually what makes the font so beautiful. So I guess a better approach might be setting lineskiplimit to negative value. For Adobe Garamond Pro this would be -0.8pt. See: tug.org/pipermail/xetex/2006-February/003179.html – user5950 Sep 25 at 12:09
• @user5950 Why wouldn't 1.07 be desirable? – egreg Sep 25 at 12:17
• @egreg I didn't want to claim that in general. But in my use case it makes a huge difference: \onelineskip becomes 12.84009pt instead of 12pt and this makes the page looking to white in my opinion. But in general increasing the \linespread seems to be the cleanest solution. And your example is very handy to find out to which value either \linespread or \lineskiplimit hast to be set. Thanks a lot, I would have never found out! – user5950 Sep 25 at 12:27

As noted in my comment, I don't have Garamond Pro, but problem confirmed for another common font, \setmainfont{Palatino Linotype}, using XeLaTeX

I presume the chapter title is placed in a box without a strut, so that descender depth affects the overall box depth. One solution is to add a \strut to the end of each chapter title.

\documentclass[a4paper,10pt,oneside]{memoir}
\usepackage{lipsum}
\usepackage{fontspec, calc}
\setmainfont{Palatino Linotype}

• @DavidCarlisle I have never used \showoutput before. What exactly am I looking for? I see a line ..\glue(\lineskip) 0.0 another ...\glue(\lineskip) 1.0, then ..\glue(\lineskip) 0.0 and again a ...\glue(\lineskip) 1.0 – Steven B. Segletes Sep 25 at 10:43
• yep I have the font (didn't realise:-) adding the strut makes the descender on the g not matter but at the cost of giving the bad case all the time (so it's consistent but ...) – David Carlisle Sep 25 at 10:44