[Tex/LaTex] How to put the QED symbol of a proof at the right place inside align

alignamsmathequationsmath-mode

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}

Best Answer

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}
Related Question