I am making use of \qedhere
in proof environments in order to avoid extra space when the proof ends in an equation. I am wondering about why it behaves differently in different environments.
- Apparently, \qedhere does not work in an
equation
environment, when using the showonlyrefs feature from themathtools
package? I get the following error:A <box> was supposed to be here. \end{equation}
- When using the
amsmath
package, it does not give an error between a pair of$$
, but it does not flush the\qed
box to the right, so it does not behave as desired. The same goes for thegather
environment. - It works in an
align
environment, but only if&
is ever used, see Strange behavior by \qedhere in align environment without alignment mark (&) - It works as desired in square brackets
\[\]
Here is a MWE:
\documentclass{article}
\usepackage{amsmath,amsthm}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs}
\begin{document}
\begin{proof}
Too much space afterwards:
\[
a=b.
\]
\end{proof}
\begin{proof}
Works fine:
\[
a=b.\qedhere
\]
\end{proof}
\begin{proof}
Not flushed right:
$$
a=b.\qedhere
$$
\end{proof}
\begin{proof}
Not flushed right:
\begin{gather}
a=b.\qedhere
\end{gather}
\end{proof}
\begin{proof}
Box completely misplaced:
\begin{align}
a=b.\qedhere
\end{align}
\end{proof}
\begin{proof}
Stuff in comments gives error.
% \begin{equation}
% a=b.\qedhere
% \end{equation}
\end{proof}
\end{document}
Why do I get these different behaviors, and what is the preferred way of using \qedhere
?