Skip to content

largestsep does not work as advertised #27

Description

@RuixiZhang42

Brief description of the bug

With package option largestsep, titlesec does not use the larger skip, but instead use the sum of <after-sep> from the first heading and <before-sep> from the second heading.

MWE demonstrating the issue

MWE adapted from https://tex.stackexchange.com/q/269484 with more exaggerated spacing:

\documentclass{article}
\usepackage{lipsum}
\usepackage[largestsep]{titlesec}
\titlespacing{\section}   {0pt}{20pt}{20pt}
\titlespacing{\subsection}{0pt}{20pt}{10pt}
\begin{document}
Expected:

\vskip20pt

\Large Section

\vskip20pt

\large Subsection

\vskip10pt

\normalsize \lipsum[1][1-5]

\noindent
\hrulefill

Actual:
\section{Section}
\subsection{Subsection}
\lipsum[1][1-5]
\end{document}

largestsep

Possible fixes

titlesec uses \vspace to add <after-sep>, and this is the bug.

In the LaTeX2e kernel \vspace{#1} expands to ... \vskip #1 \vskip\z@skip ..., so when the next <before-sep> appears in \ttl@titlespace{<before-sep>} (since \let\ttl@titlespace\addvspace in this case), the \addvspace acts on \z@skip and not the intended <after-sep>.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions