josephwright / josephwright/beamer

Unwanted horizontal shift of displayed equations on overlay when `\label` is present

Open
#960 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
1.7k
Forks
164
PR merge metrics
No merged PRs in 30d

Description

Description

When a \label is placed inside a displayed equation environment (equation or equation*) in a frame with overlays, the equation shifts horizontally when advancing from one overlay to the next. The shift does not occur when \label is absent.

Minimal reproducible example

\documentclass{beamer}
\begin{document}

\begin{frame}{Test}
  \begin{equation*}\label{E:Test}
    A,
  \end{equation*}
  \pause
  Text.
\end{frame}

\end{document}

Observed behavior

On overlay 1, the equation appears at one horizontal position. After advancing to overlay 2, the equation shifts slightly to the right.

Expected behavior

The equation should remain at the same horizontal position across all overlays.

Conditions identified so far

The following conditions trigger the bug (the list may not be exhaustive):

  • \label present inside equation or equation* — this appears to be a necessary condition in all cases identified so far;
  • the equation ends with , or ; (\mathpunct), or contains an operator defined via \DeclareMathOperator.

The following conditions prevent the bug:

  • \label removed from the equation environment;
  • \label moved to the very end of the equation, just before \end{equation*} (see workaround below).

Suspected cause

During the overlay retypesetting pass, \label triggers a write to the .aux file. This side effect appears to disturb the internal state of display math mode at the moment the final content is processed. Elements that involve spacing adjustments via \mskip — such as \mathpunct characters (,, ;) and operators defined via \DeclareMathOperator — appear to be sensitive to this disturbance, whereas . (which is not a \mathpunct in math mode) is not.

Workaround

Move \label to the end of the equation, just before \end{equation*}:

\begin{equation*}
  A,
  \label{E:Test}
\end{equation*}

Alternatively, remove \label from equation* entirely, since an unnumbered equation cannot be meaningfully referenced. Note, however, that keeping labels in equation* in slides that share code with a book may be a legitimate use case.

Environment

  • MiKTeX (updated), March 2026
  • The problem was not present in August 2025 and began occurring by March 2026 or before, suggesting it was introduced by an update to Beamer or one of its dependencies in that interval.

References

This bug was first documented on TeX Stack Exchange: https://tex.stackexchange.com/questions/761045/unwanted-horizontal-shift-of-equation-on-overlay-when-label-is-present-and-equ

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the minimal beamer example in the issue with MiKTeX and compare the equation position across overlays, then investigate the overlay retypesetting and label handling involved. Reproduce the cases with punctuation, declared operators, and the label moved to the end; done means the equation no longer shifts and the reported workaround cases remain understood.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.