# qed symbol not correctly aligned when ending a proof with a diagram

I know there is a myriad of questions about the alignment of the tombstone symbol, but I couldn't see any one that addresses this little issue.

Say you end your proof with a diagram such as the following:

$\xymatrix{A & B \\ C & D}$

Then the little tombstone symbol will be way one line further down from where it should be. If I add \qedhere just after the diagram, then the tombstone is aligned with the B in the diagram, which is just wrong.

How do I get it right?

MWE:

\documentclass{article}
\usepackage{amsmath,amsthm}
\usepackage[all,cmtip,2cell]{xy}
\newtheorem{theorem}{Theorem}

\begin{document}
\begin{theorem} A theorem.
\begin{proof}
$\xymatrix{A & B \\ C & D}$
\end{proof}
\end{theorem}

\begin{theorem} A theorem.
\begin{proof}
$\xymatrix{A & B \\ C & D} \qedhere$
\end{proof}
\end{theorem}

\end{document}

-
Can you give a minimal working example (MWE) that shows the issue? – Johannes_B Apr 23 '14 at 16:21
@Johannes_B: I can. – lentic catachresis Apr 23 '14 at 16:25

Three possible styles:

\documentclass{article}
\usepackage{amsmath,amsthm}
\usepackage[all,cmtip]{xy}
\begin{document}
\begin{proof}
$\xymatrix{A & B \\ C & D} \qedhere$
\end{proof}
\begin{proof}
$\begin{gathered} \xymatrix{A & B \\ C & D}\\ \end{gathered} \qedhere$
\end{proof}
\begin{proof}
$\begin{gathered}[b] \xymatrix{A & B \\ C & D}\\[-\dp\strutbox] \end{gathered} \qedhere$
\end{proof}
\end{document}


In the last one, the adjustment may depend on what's in the bottom row of the diagram.

-
Magic. I've no idea how it works but the last one does just what I want. Thanks. – lentic catachresis Apr 23 '14 at 16:29
@BrunoStonek I use \begin{gathered}[b] that sets the reference point at the bottom row of itself; however, I have to use a fake second row, which is empty, which \qedhere uses for the reference point; but some adjustment has to be made, because each cell in the \xymatrix has a \strut in it, so I backup by its depth. – egreg Apr 23 '14 at 16:32
@egreg: Makes me wonder why amongst the myriad of theorem packages, no-one seems to have tried a zero-height line with a smashed tombstone at the end, but that would probably put the tombstone even further down than your third variant. – Ulrich Schwarz Apr 23 '14 at 17:51
@UlrichSchwarz “There are more things in heaven and earth, Horatio, Than are dreamt of in your philosophy”: what about a last line almost full, with the smashed tombstone overlapping with text? ;-) – egreg Apr 23 '14 at 17:55