# Ensuring consistent line spacing with ascenders, descenders and accents

This is basically a follow-up question to Consistent Line Spacing in Customized Titles.

It appears to me that \strut can only work in macros taking one- or two-line (in the output) arguments, so I am interested in the more general issue. What is the mechanism causing lines to adapt their baseline position based on their descenders and ascenders? Can this mechanism be manipulated to make at least text and titles align to a grid? I understand math, tables and figures are a new level of complication, so let's focus on text for now. Does font and font size have any impact?

Titles may be a bad example as they are supposed to be max a line or two, but the same general problem should apply to other environments like quotes.

In the following example adapted from the original question, accents are adding a lot to the line space, and if on the other hand only lowercase (or small caps) letters are used, we lose some space.

\makeatletter
\documentclass{report}
\usepackage{lipsum}

\newbox\chapstrutbox
\def\chapstrut{\relax\ifmmode\copy\chapstrutbox\else\unhcopy\chapstrutbox\fi}
\setbox\chapstrutbox\hbox{%
\vrule\@height3\baselineskip\@depth2\baselineskip\@width\z@}%
\def\offinterlineskip{\baselineskip-1000\p@%
\lineskip\z@ \lineskiplimit\maxdimen}

\let\myskip\baselineskip
\noindent\chapstrut\fontsize{\@xxpt pt}{2\myskip}\selectfont%
#1\chapstrut\par\nobreak}}
\noindent\chapstrut\fontsize{\@xxpt pt}{2\myskip}\selectfont%
#1\chapstrut\par\nobreak}}

\makeatother
\begin{document}
\chapter{\'{A}ccent\d{y}ated han\d{g}in\d{g} c\'{h}aracters and a \'{l}ot of
text to ma\d{g}e it \'{f}\'{l}ow over \d{j}nto several \'{l}\d{y}nes\d{,}
\d{y}ou ne\d{y}er \'{k}now when \d{y}ou mi\d{g}\'{h}\'{t} need a \'{t}itle
tha\'{t} is stu\d{p}idl\d{y} \'{l}on\d{g} (exce\d{p}t \d{y}ou do \'{b}ecause
\'{t}ha\d{y}t\'{'}s w\'{h}at s\d{y}bhea\'{d}in\d{g}s are \'{f}or)}
\lipsum[1-2]
\chapter{A title with a hanging character and a lot of text to make it flow
over into several lines, you never know when you might need a title that is
stupidly long (except you do because that's what subheadings are for)}
\lipsum[1-2]
\chapter{avv avove ovne coaraccers anz a woo os rexr co mave xc swow over enco
severar renes -- vou never cnow wwen vou meewc neez a cecre cwac es scuvezre
ronw -- excevc vou zo vecause cwac-s wwac suvweazenws are vor --}
\lipsum[1-8]
\end{document}


• I changed to still images instead. 20.74pt should fit within 24pt? and even if not, is there a way to tell TeX to force baseline alignment, no matter if it would overlap? And what is going on with the lowercase-only title? Why is its line height compressed? Feb 28 '18 at 21:25
• thanks for stopping the animation:-) no the text does not fit in a 24pt baseline, your first text lines have height plus depth of 19.87715+7.96652 which is a fair bit bigger than 24pt Feb 28 '18 at 21:39
• I don't think you want to use it at all in this context but why redefine the standard \offinterlineskip ? Feb 28 '18 at 21:44
• Typically \baselinekip=\dimexpr \ht\strutbox+\dp\strutbox\relax. I usually add \struts at the beginning and end of a \parbox or minipage where \baselineskip isn't used. Feb 28 '18 at 22:48
• I read about \lineskiplimit in this question, which combines with this to an acceptable workaround. Jul 30 '18 at 8:32

The main issue is that the text is larger than the specified baselineskip so \lineskip spacing is used which never gives even spacing, see the log on page1.

If you want even spacing, the normal thing to do is increase the baselineskip as on page 2.

If you want even spacing within a paragraph but closer spacing for lowercase text (a bit unusual but...) then you can first set the text in a horizontal box, then measure its height plus depth, then set \baselineskip to be larger than this, as on page3.

\documentclass{report}

\showoutput\showboxdepth3
\begin{document}
\makeatletter

\def\testa{%
\'{A}ccent\d{y}ated han\d{g}in\d{g} c\'{h}aracters and a \'{l}ot of
text to ma\d{g}e it \'{f}\'{l}ow over \d{j}nto several \'{l}\d{y}nes\d{,}
\d{y}ou ne\d{y}er \'{k}now when \d{y}ou mi\d{g}\'{h}\'{t} need a \'{t}itle
tha\'{t} is stu\d{p}idl\d{y} \'{l}on\d{g} (exce\d{p}t \d{y}ou do \'{b}ecause
\'{t}ha\d{y}t\'{'}s w\'{h}at s\d{y}bhea\'{d}in\d{g}s are \'{f}or)}

\def\testb{%
A title with a hanging character and a lot of text to make it flow
over into several lines, you never know when you might need a title that is
stupidly long (except you do because that's what subheadings are for)}

\def\testc{%
avv avove ovne coaraccers anz a woo os rexr co mave xc swow over enco
severar renes -- vou never cnow wwen vou meewc neez a cecre cwac es scuvezre
ronw -- excevc vou zo vecause cwac-s wwac suvweazenws are vor --}

{\fontsize{\@xxpt pt}{2\baselineskip}\selectfont

\testa

\testb

\testc

}

\clearpage

{\fontsize{\@xxpt pt}{30pt}\selectfont

\testa

\testb

\testc

}

\clearpage

{\fontsize{\@xxpt pt}{30pt}\selectfont
\def\zz#1{{\sbox0{#1}\baselineskip 1.2\dimexpr\ht0+\dp0\relax \unhbox0 \par}}

\zz{\testa}

\zz{\testb}

\zz{\testc}

}

\end{document}