latex3 / latex2e

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

\qedhere in equation (fleqn) doesn't print \qed in the proof #783

Open linasstonys opened 2 years ago

linasstonys commented 2 years ago

qed_bug2.pdf

Brief outline of the bug

amsmath loaded with 'fleqn' doesn't print qed symbol in the proof environment. If amsthm is loaded before amsmath it does print qed but at the left sided of equation.

Adding \alt@tag in the tag box fixes the issue.

\def\endmathdisplay@fleqn {%
$\hfil \hskip \@mathmargin \egroup \ifnum \badness <\inf@bad \let \too@wide \@ne \else \let \too@wide \z@ \fi \ifx \@empty \df@tag 
\else \setbox 4\hbox {%
\alt@tag % <--HERE
\df@tag \ifx \df@label \@empty \else \@xp \ltx@label \@xp {\df@label }\fi }\fi 
\csname emdf@\ifx \df@tag \@empty U\else \iftagsleft@ L\else R\fi \fi \endcsname 
}

Other environments seems to be ok.

Minimal example showing the bug

\RequirePackage{latexbug}       % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{amsthm}

  % Any preamble code goes here

\begin{document}

  % Demonstration of issue here
\begin{proof}
Without QED
\begin{equation}
a+b
\qedhere
\end{equation}
\end{proof}

\begin{proof}
With QED
\begin{equation*}
a+b
\qedhere
\end{equation*}
\end{proof}

\end{document}

Log file (required) and possibly PDF file

eg9 commented 2 years ago

Not sure this is the right place. The suggested fix indeed works, but it might break existing documents, although this would be quite a rare situation, because using \qedhere in an equation with reqno makes for bad typesetting.

However, the same issue happens when leqno is in effect and in this case the \qedhere has no effect either.

In summary, I favor the fix.

stale[bot] commented 2 years ago

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