It is common to place a \qed-Box at the end of a theorem statement (or lemma, corollary, ...) if we give no proof for that statement.

How can I do this in LaTeX? If I place a qed-box at the end of the statement there is an additional linebreak, which is inacceptable formating.


if you are using amsthm or an ams document class, this problem is addressed by an item in the ams author faq. this in turn links to an example document that covers quite a few of the possible situations in which such a marker could be wanted. the most extreme situations require some manual effort, but i believe that nearly all reasonable possibilities (including the non-proof ending with a display) are covered.

  • 14
    Link appears dead. – wchargin Jul 18 '15 at 3:33
  • links are not dead, but the link to the example document is on an ftp server. some institutions restrict access to ftp servers through strict firewalls. that is unfortunate. more unfortunate is the fact that the tool used at ams to update the web server trashes tex code (it doubles backslashes without warning), so posting a tex source file of this size is not reliable. – barbara beeton Oct 14 '16 at 15:01
  • 2
    Oh, good point! I grabbed and re-uploaded the file at gist.github.com/wchargin/b3825f2dd3f17cf24532a8cf360a0e94. It compiles fine under pdflatex, so doesn't seem to have been mangled. – wchargin Oct 14 '16 at 20:32
  • @wchargin -- files on a (linux-based) ftp server are reliable. it's the tool that posts files to be fed from the ams web server that corrupts nice well-behaved ascii. we can zip such files, and that's reliable, but not everyone finds unzipping them "obvious". – barbara beeton Oct 14 '16 at 21:13
  • Ah, that makes more sense. Thanks for clarifying. – wchargin Oct 14 '16 at 22:28

With the theorem packages you would normally use \qed or \qedhere. Without those you use the commands below depending on if you want the filled square or empty:

enter image description here



Lorem ipsum \QEDA

Lorem ipsum \QEDB

  • 3
    This is not guaranteed to place the QED symbol at the end of the line – egreg Oct 14 '16 at 8:41

Sometimes it is usefull to create a minimal example:

Text Text Text \qed

You could add the \qedsymbol to the end of your theorem automatically. The etoolbox package provides the means to tap into the end of an environment using \AtEndEnvironment{<env>}{<code>}. This adds <code> at \end{<env>}.

enter image description here

\usepackage{amsthm}% http://ctan.org/pkg/amsthm
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
This is an important theorem.

However, this is only beneficial if you do not also include a \qedsymbol with your proofs. Moreover, it may cause undesired effects if you end your theorem with an equation. Regardless, you have some options:

  • Define a non-proof-theorem environment which adds this automatically; or
  • add it manually using some of the other answers provided; or
  • provide (say) a starred version of theorem (that is, theorem*) which does the above.
  • Peter Grill gives a nice answer,it works! – user16950 Jul 26 '12 at 8:44
  • This is not guaranteed to place the QED symbol at the end of the line. – egreg Oct 14 '16 at 8:40

Late to the party, but my answer is as follows:

To insert a QED symbol:

Case 1: Last line of text is to be centre-aligned:

\hfill <last line of code> \hfill $\square$

Case 2: Centre-alignement is not required:

<last line of code> \hfill $\square$

This works inside any environment and even if the last line is an equation, in which case you have to use $\displaystyle <equation>$ instead of \[ \]

Or if you like, use \lozenge instead of $\square$ to have a different QED symbol.

  • 2
    Might not be such a good idea, it does not disencourage a page break before the square and if the line is full, the hfill will probably die and the square ends up at the left margin instead of the right. Have a look at the \qed implementation in amsthm, we see a lot of the constructions like you present here, they are not to be encouraged. – daleif Jan 30 '14 at 10:06

To get the symbol used for typesetting the QED, use \qedsymbol:

\begin{theorem}Foo is a bar.\eolqed
  • 1
    There is no need for \ensuremath here. – Werner Nov 7 '11 at 19:20
  • This is not guaranteed to place the QED symbol at the end of the line. – egreg Oct 14 '16 at 8:40
  • \def\eolqed{\hfill\qedsymbol} would also do the trick. – Nicolas Schmidt Mar 19 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.