# How to adjust the QED symbol to appear just after the last word in a proof

Whenever I finish a proof I tend to put the little square just after the last word, but by using the /begin{proof} /end{proof} environment it appears always at the end of the line. It seems like its definition would include the /hfill command but I don't know how to leave it out. How can I fix it?

• the end-of-line position was chosen as the ams style because it's easy to spot on a page. the "open box" tends to blend in with the text when it's in the middle of a line, and a black box was felt to be to prominent. this also affects the placement of equation numbers: for ams style, they are on the left so that they do not conflict with the qed marker. (of course, different authors may have different preferences.) Apr 24, 2015 at 14:05

You have to patch the \qed command.

\documentclass{article}

\usepackage{amsthm}

%% using xpatch
\usepackage{xpatch}
\xpatchcmd{\qed}{\hfill}{}{}{}

%% Or without any package
%\DeclareRobustCommand{\qed}{%
%  \ifmmode % if math mode, assume display: omit penalty etc.
%  \else \leavevmode\unskip\penalty9999 \hbox{}\nobreak%\hfill
%  \fi

\begin{document}

\begin{proof}
This is some proof.
\end{proof}

\end{document}


The separation is \quad. You can change that also similarly, i.e.,

\xpatchcmd{\qed}{\quad}{\space}{}{}  %% \space may be \hspace{<length>}

• if the last line of a proof ends so far to the right that there is not room for the qed, the box will go to the start of the next line, where it's not so easy to spot. what tactic should be used there to make it more visible? Apr 24, 2015 at 14:07

Proof environment is defined in the amsthm package with the qedsymbol being put at the right end of the page. You can redefine the qedsymbol not to produce anything and define your own qed symbol and use that inside proof environment like this:

\usepackage{amssymb}
\renewcommand\qedsymbol{}
\newcommand\myqed{$\blacksquare$}

\myqed can be used wherever required.

• I just tried this solution. Actually instead of defining a new command I'm trying to do it by a definition of a a new environment. The problem is when trying it with the environment or for example when using /[ /] the \blacksquare symbol appears always just at the beginning of the next line. How can I eliminate the new line produced by the equation environment? Apr 24, 2015 at 4:33
• \qedhere command provided by amsthm package does that exactly. Apr 24, 2015 at 4:39

No need to use xpatch or any package, nor do you have to use \DeclareRobustCommand. All you have to do is renew the /qed command. Your document should look something like this:

\documentclass{article}

\usepackage{amsthm}


I used \quad for my space but you can use whichever size space you would prefer.