latex2e icon indicating copy to clipboard operation
latex2e copied to clipboard

Vertical spacing with headings holding capital umlauts

Open mrpiggi opened this issue 4 years ago • 6 comments

Brief outline of the bug

Using a capital umlaut with \section or \subsection causes a vertical shift of the heading as it occupies more space than reserved. So using \section{Ä title} instead of \section{A title} leads to different vertical spacing and consequently maybe to differing paragraph or page breaks.

The first try using \strut within the heading just shifts the problem to the first line after the heading. The naive approach with something like \newcommand*\naivestrut{\vphantom{\textsuperscript{\"A\"O\"U}}} gives at least a uniform result.

Minimal example showing the bug

\RequirePackage{latexbug}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\begin{document}
\section{A title}
A \blindtext
\clearpage
\section{A title}
Ä \blindtext
\clearpage
\section{Ä title}
Ä \blindtext
\clearpage
\section{Ä title}
A \blindtext
\clearpage

\section{\strut A title}
A \blindtext
\clearpage
\section{\strut A title}
Ä \blindtext
\clearpage
\section{\strut Ä title}
Ä \blindtext
\clearpage
\section{\strut Ä title}
A \blindtext
\clearpage

\newcommand*\naivestrut{\vphantom{\textsuperscript{\"A\"O\"U}}}
\section{\naivestrut A title}
A \blindtext
\clearpage
\section{\naivestrut A title}
Ä \blindtext
\clearpage
\section{\naivestrut Ä title}
Ä \blindtext
\clearpage
\section{\naivestrut Ä title}
A \blindtext
\clearpage

\end{document}

Log file (required) and possibly PDF file

mrpiggi avatar Feb 22 '21 08:02 mrpiggi

Why don't you enlarge \topskip?

I don't think it is a bug. Why should the code adapt to german? There are other languages with more accents which probably would need even more spaces. But changing section so that every language fits in, would create too much space for languages without accents. So what is needed is some strut that user can adapt to their needs.

u-fischer avatar Feb 22 '21 09:02 u-fischer

A \topskip would show up in other places too @u-fischer where it would be noticeable and not desired.

It is, if you like, a deficiency of TeX itself which has a somewhat simpleminded model around \topskip and the like. So I agree the right approach is a strut in the heading that only affects the height. But it is nothing that can be implemented in standard classes without invalidating millions of documents as their pagination change. So bottom line it is "works as (badly) designed" and more elaborate classes are free to add such a strut in the configurations of headings.

FrankMittelbach avatar Feb 22 '21 09:02 FrankMittelbach

One option in a given document would be to apply \smash to the section title (or only to the Ä?) It seems to give consistent spacing.

blefloch avatar Feb 22 '21 13:02 blefloch

as a one-off yes, as a more general solution I think document classes should define headings so that they deploy a reasonable topskip that fits the fonts they use. for backwardcompatibility I don't see that anything can be done to the standard classes or to the default kernel code. That can only be done if we provide a new set of classes (in addition to existing ones)

FrankMittelbach avatar Feb 22 '21 16:02 FrankMittelbach

As Frank correctly assumed, I was looking for a general solution to the problem. I had already implemented something in my classes, but originally used \strut incorrectly, which may have resulted in a vertical baseline shift of the first line after the heading. Thanks to all for the suggestions. As far as I am concerned, the topic can be closed.

mrpiggi avatar Feb 23 '21 16:02 mrpiggi

I'll keep it on long term as it is something to keep in mind.

FrankMittelbach avatar Feb 23 '21 20:02 FrankMittelbach