Skip to content

Step-annotation columns overflow the PDF text block, clipping justifications off the page #1154

Description

@d-morrison

Important

This issue's original measurements were wrong and have been replaced.
The corrected figures and instrument are below; the history is in the
comments.

CLAUDE.md asks every derivation step to carry a trailing justification.
When that justification sits in a third && column of an aligned block, it
adds its own width to the block, and wide derivations then overflow the text
block in the PDF profiles --- so the justification is clipped off the right
edge of the page
, which is exactly the content the rule exists to supply.
HTML is unaffected, so the pre-commit checklist cannot see it.

Measurement

Against the book's own class and geometry (scrbook, twoside=off,
top=15mm bottom=20mm), with the text width read from the run via
\showthe\textwidth rather than assumed:

arm text width LaTeX errors overfull worst
origin/main (873b4a09) 418.25pt 0 1 47.2pt
#1138 before its fix 418.25pt 0 11 139.7pt
#1138 after its fix 418.25pt 0 0 ---

So main's existing exposure is one box at 47pt --- small, but the count
grows with every chapter that gains step annotations.

Two instrument traps, both of which produced wrong numbers here

  1. latex-macros is a submodule, so git show <ref>:latex-macros/macros.qmd
    returns empty. A harness that reads the macros that way compiles the
    comparison arm with no macros at all. That is what produced this issue's
    original "8 overfull, worst 153.4pt" for main, and the "~345pt text
    width" was assumed rather than measured. Read the macros from disk; the
    submodule pin is unchanged by Improve narrative flow and math derivations in count regression chapter #1138.
  2. quarto pandoc does not process {{< include >}}, and injecting
    macros.qmd into a hand-assembled .tex after \begin{document} skips
    Pandoc's latex_macros expansion entirely. Either mistake makes macros
    such as \sb reach LaTeX unexpanded, which changes every width and
    invents errors. Concatenate macros.qmd's content into the document, or
    use quarto render --to latex. See
    #1152.

What does not work, and why

Shortening the annotation text. An aligned block's width is the sum of its
column maxima, so a third column holding the justification adds its width
to every row no matter how the rows are arranged; trimming words moves the
maximum slightly and nothing else. This was tried first in #1138 and took the
worst case only from 390.6pt to 139.7pt.

What works

Move the annotation onto its own row in column 2, so the width becomes the
maximum of equation and annotation rather than their sum:

&= \pi \cdot 1 + (1-\pi) e^{-\mu_0} \\
&\quad \text{(substituting the two conditional PMFs)} \\

Applied to all 40 annotated steps in the count-regression chapter, this gives
zero overfull boxes.

The open decision

Whether the rest of the book should adopt the column-2 style. It changes the
look of every annotated derivation, so it is a decision rather than a
cleanup, and #1138 deliberately confines it to its own chapter. A CI check
counting overfull boxes per chapter would keep the problem from growing
silently either way; it pairs naturally with #1152.

Filed by Claude Code (AI agent).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions