41

When a proof ends with a formula in equation or equation* environment, putting \qedhere after the equation would cause the QED symbol to appear in the right place. I.e. at the end of the line in which the equation appears. For example:

\begin{equation}
  x = y+z \qedhere
\end{equation}

However, I cannot get the same result when the formula is inside an align/align* environment using the same method:

\begin{align}
  x &= a+b \\
    &= y+z \qedhere
\end{align}

The square appears just after (y+z) and is not shifted to the right boundary of the page.

Here is a MWE:

\documentclass[a4paper]{article}
\usepackage{hyperref}
\usepackage{amsthm}
\usepackage[cmex10]{amsmath}
\interdisplaylinepenalty=2500
\usepackage{amssymb}

\title{Example to Show QED is Misplaced}
\author{}
\begin{document}
\begin{proof}
  This proof is typeset correctly:
  \begin{equation*}
    x = y + z \qedhere
  \end{equation*}
\end{proof}

\begin{proof}
  But this one not!
  \begin{align*}
    x & = u + v \\
    & = y + z \qedhere
  \end{align*}
\end{proof}

\end{document}
5
  • Why don't you use the proof environment of the acm packages? Aug 29, 2013 at 9:50
  • ntheorem might also be worth a look
    – moewe
    Aug 29, 2013 at 9:54
  • It appears at the right margin in my experiment (but it has the side effect of removing the equation number). Can you show a minimal working example (MWE)?
    – egreg
    Aug 29, 2013 at 9:58
  • I added a MWE to the end of my question. I am sorry, I don't know how can I upload the MWE file directly.
    – MikeL
    Aug 29, 2013 at 11:30
  • @ManiBastaniParizi The cmex10 option to amsmath may be needed only with very old TeX installations; don't use it unless you get a Math formula deleted error. In this case, first try updating your TeX distribution.
    – egreg
    Aug 29, 2013 at 16:32

2 Answers 2

38

Change the order, this works just fine, amsthm after amsmath, otherwise it might be a bit hard for it to hook into align*

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\interdisplaylinepenalty=2500
\usepackage{amssymb}
\usepackage{hyperref}

\title{Example to Show QED is Misplaced}
\author{}
\begin{document}
\begin{proof}
This proof is typeset correctly:
\begin{equation*}
x = y + z \qedhere
\end{equation*}
\end{proof}

\begin{proof}
But this one not!
\begin{align*}
x & = u + v \\
& = y + z \qedhere
\end{align*}
\end{proof}

\end{document}
4
  • 5
    with the package order amsthm before amsmath, a warning is issued: Package amsthm Warning: The \qedhere command may not work correctly here on input line .... it's also documented in the first section of amsthdoc that "amsthm must be loaded after amsmath, not before." Aug 29, 2013 at 14:30
  • Another caveat, be sure to have all the & in the last line. If the preceding lines contained for example there & don't forget to use all of them on the last line too.
    – Yrogirg
    Oct 20, 2015 at 1:58
  • When I do this, my QED symbol overlaps on top of the text inside the align* environment. Is there any way to fix this?
    – crxyz
    Jan 24, 2023 at 2:26
  • 1
    @CrazyVideoGamer please post a question of your own including a suitable minimal example.
    – daleif
    Jan 24, 2023 at 8:43
15

Section 5 of the amsthm package documentation contains the following.

When used with the amsmath package, version 2 or later, \qedhere will position the QED symbol flush right; with earlier versions, the symbol will be spaced a quad away from the end of the text or display. If \qedhere produces an error message in an equation, try using \mbox{\qedhere} instead.

However, when I tried this with your example I got a QED symbol one quad away from the end of the display, despite the fact that my distribution contains amsmath version 2.13. However, using

\tag*{\qedhere} 

instead solved the problem.

4
  • 1
    see the second paragraph of section "1 introduction" of amsthdoc. (i had to check, because if it didn't already say that the loading order is important, i would have to add it to the list of bugs. glad i don't have to.) Aug 29, 2013 at 14:32
  • @barbarabeeton Consider the following code: \documentclass{article} \usepackage{amsmath} \usepackage{amsthm} \begin{document} \begin{proof} \begin{alignat*}{2} &x && =1 \\ &y && =2 \qedhere \end{alignat*} \end{proof} \end{document} amsmath is loaded before amsthm, yet latex issues a warning. The warning is not issued if align is used instead of alignat (but the result is ugly). Am I misusing alignat or is there an issue here?
    – brad
    Jul 20, 2023 at 13:27
  • @brad -- alignat* should work the same as align*. I'm not able to test this right now, but surely this deserves its own question, so please post one. (That will also make ie easier to copy and paste the example code. I'm not at all sure why the first {2} is in braces, but that shouldn't make any difference.) Please also show the warning that is issued. Jul 20, 2023 at 15:34
  • @barbarabeeton : I did, cfr. here. Thank you.
    – brad
    Jul 20, 2023 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .