# End of proof symbol in tikz environment

I have a (tikz) diagram (a matrix of math modes) at the end of a proof and would like to place the end of proof symbol on the height of the last line of the diagram. I tried to place \qedhere in the last line, but tikz complains

Package tikz Error: Giving up on this path. Did you forget a semicolon?


(Needless to say, the file compiles without problems without \qedhere.)

Edit. My original problem could be reproduced with the following MWE.

\documentclass[12pt,a4paper]{report}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.markings}
\usepackage{amsthm}
\usepackage{amsmath}
\begin{document}
\begin{proof}
The proof is complete by staring at the following diagram
$\begin{tikzpicture} \matrix (m) [matrix of math nodes, row sep=2em, column sep=2em] { 0 & A & B \\ 0 & C & D \qedhere \\ } ; \path[->] (m-1-1) edge (m-1-2) (m-1-1) edge (m-2-1) (m-2-1) edge (m-2-2) (m-1-2) edge (m-2-2) ; \end{tikzpicture}$
\end{proof}

\begin{proof}
For comparison, this is where the end of proof symbol should be:
\end{proof}
\end{document}


Loading the tikz package last, gives no error during compilation, but leaves the QED symbol inside the node. I would like it to align vertically with the proof symbols from other proofs, i.e. at the very end of the line.

• here is not defined in a tikzpicture. You can place it outside the Tikzpicture or put a black square next to the matrix. – percusse Oct 22 '14 at 21:09
• You can try \qed instead (with amsthm). But, it would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that reproduces the problem. – Peter Grill Oct 22 '14 at 21:11
• I suggest you give a try at the ntheorem package, which has a very efficient automatic placement of end-of-theorem symbols (including amsmath environments). Should you decide to test it, don't forget to load it with the thmmarks option. – Bernard Oct 22 '14 at 21:12
• @PeterGrill Please see my edit. \qed just places the QED symbol at the current location. I would like it to be at the end of the line, like all other QED symbols. – Earthliŋ Oct 22 '14 at 22:28

I'd suggest you use qedhere after \end{tikzpicture}:

Alternatively, if you want it aligned with the last line you can place the node with

\node [anchor=east,overlay,inner sep=0, outer sep=0] at (m-2-2 -| 0.5\textwidth,0) {\qedhere};


## Code: \qedhereaftertikzpicture:

\documentclass[12pt,a4paper]{report}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.markings}
\usepackage{amsthm}
\usepackage{amsmath}
\begin{document}
\begin{proof}
The proof is complete by staring at the following diagram
$\begin{tikzpicture} \matrix (m) [matrix of math nodes, row sep=2em, column sep=2em] { 0 & A & B \\ 0 & C & D \\ } ; \path[->] (m-1-1) edge (m-1-2) (m-1-1) edge (m-2-1) (m-2-1) edge (m-2-2) (m-1-2) edge (m-2-2) ; \end{tikzpicture}\qedhere$
\end{proof}

\begin{proof}
For comparison, this is where the end of proof symbol should be:
\end{proof}
\end{document}


## Code: Use \node to place \qed:

\documentclass[12pt,a4paper]{report}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.markings}
\usepackage{amsthm}
\usepackage{amsmath}
\begin{document}
\begin{proof}
The proof is complete by staring at the following diagram
$\begin{tikzpicture} \matrix (m) [matrix of math nodes, row sep=2em, column sep=2em] { 0 & A & B \\ 0 & C & D \\ } ; \path[->] (m-1-1) edge (m-1-2) (m-1-1) edge (m-2-1) (m-2-1) edge (m-2-2) (m-1-2) edge (m-2-2) ; \node [anchor=east,overlay,inner sep=0, outer sep=0] at (m-2-2 -| 0.5\textwidth,0) {\qedhere}; \end{tikzpicture}\qedhere$
\end{proof}

\begin{proof}
For comparison, this is where the end of proof symbol should be:
\end{proof}
\end{document}

• I don't know why, but in my document with this solution, the qed symbol appears much higher than in the MWE. In any case, even with your suggestion, the qed symbol is not exactly on the line. Is there a way to adjust the height manually? – Earthliŋ Oct 22 '14 at 22:57
• @Earthliŋ: Ok, have provided an alternate solution. – Peter Grill Oct 22 '14 at 23:14
• Oh, very pretty. I don't quite understand the syntax -| .5\textwidth,0), but it gives exactly what I want. Thank you! – Earthliŋ Oct 23 '14 at 0:07