Skip to content

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

Description

@profjoaoalvesjr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions