# How to put the QED symbol of a proof at the right place inside align?

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:

$$x = y+z \qedhere$$


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}

-
Why don't you use the proof environment of the acm packages? –  CommuSoft Aug 29 '13 at 9:50
ntheorem might also be worth a look –  moewe Aug 29 '13 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 '13 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. –  Mani Bastani Parizi Aug 29 '13 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 '13 at 16:32

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}

-
Thank you very much :-)! –  Mani Bastani Parizi Aug 29 '13 at 12:10
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." –  barbara beeton Aug 29 '13 at 14:30

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}


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.) –  barbara beeton Aug 29 '13 at 14:32