latex3 / latex2e

The LaTeX2e kernel
https://www.latex-project.org/
LaTeX Project Public License v1.3c
1.87k stars 262 forks source link

Guard against rebox #517

Closed RuixiZhang42 closed 1 year ago

RuixiZhang42 commented 3 years ago

Brief outline of the bug

TeX the program has a rebox subroutine, which is used when constructing (1) fraction’s numerator or denominator, and (2) big operator’s limits (and the operator itself). This subroutine does not retain the height and depth of the content box, so after reboxing these data are lost and can lead to bad interactions with some plain TeX macros (e.g., \smash, \phantom, etc.). A minimal plain TeX example is:

\def\drawbaseline{\rlap{\vrule width 50pt height 0.1pt depth 0pt }}
\noindent
This is okay: $${1\over\drawbaseline2}+{1\over\smash{2^2}}$$
This is not: $${100\over\drawbaseline2}+{100\over\smash{2^2}}$$
\bye

I reported this issue to Karl Berry and it was forwarded to Don Knuth for the 2021 tuneup. Unfortunately, according to Karl, Don Knuth declined to offer any fixes to either the program or the plain TeX format, with no explanations. Karl said that the same problems could “leak” into LaTeX and advised me to report them here.

Minimal example showing the bug

%\RequirePackage{latexbug}       % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}
\newcommand*\drawbaseline{\rlap{\vrule width 50pt height 0.1pt depth 0pt }}
\begin{document}
\noindent
This is okay:
\[
\frac{1}{\drawbaseline2}+\frac{1}{\smash{2^2}}
\]
This is not:
\[
\frac{100}{\drawbaseline2}+\frac{100}{\smash{2^2}}
\]
\end{document}

Log file (required) and possibly PDF file

I can’t get LaTeX to run with \RequiarePackage{latexbug} because it keeps saying l3backend is managed by third party, sorry… Not a good time for update either because other deadlines.

josephwright commented 3 years ago

I can’t get LaTeX to run with \RequiarePackage{latexbug} because it keeps saying l3backend is managed by third party, sorry

Not related to the report, but for me with an up-to-date latexbug there is no error with your demo.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity.

muzimuzhi commented 1 year ago

Just to make things linked, it's resolved by #914.