Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
See this or this or this question. –  Marco Nov 7 '11 at 19:09
add comment

6 Answers

up vote 9 down vote accepted

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.

share|improve this answer
1  
This is a good reference! –  Werner Nov 7 '11 at 19:28
add comment

Sometimes it is usefull to create a minimal example:

\documentclass{article}
\usepackage{amsmath,amsthm}
\newtheorem{lem}{Lemma}
\usepackage{lipsum}
\begin{document}
\begin{lem}
Text Text Text \qed
\end{lem}
\end{document}
share|improve this answer
add comment

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

\documentclass{article}
\usepackage{amsthm}% http://ctan.org/pkg/amsthm
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\newtheorem{theorem}{Theorem}%
\AtEndEnvironment{theorem}{\null\hfill\qedsymbol}%
\begin{document}
\begin{theorem}
This is an important theorem.
\end{theorem}
\end{document}

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.
share|improve this answer
    
Peter Grill gives a nice answer,it works! –  user16950 Jul 26 '12 at 8:44
add comment

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

\documentclass[border=2pt]{standalone}
\usepackage{amssymb}

\newcommand*{\QEDA}{\hfill\ensuremath{\blacksquare}}%
\newcommand*{\QEDB}{\hfill\ensuremath{\square}}%

\begin{document}
Lorem ipsum \QEDA

Lorem ipsum \QEDB

\end{document}
share|improve this answer
add comment

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

\documentclass{minimal}
\usepackage{amsmath,amsthm}
\newtheorem{theorem}{Theorem}
\def\eolqed{\hspace{\stretch1}\ensuremath\qedsymbol}
\begin{document}
\begin{theorem}Foo is a bar.\eolqed
\end{theorem}
\end{document}
share|improve this answer
    
There is no need for \ensuremath here. –  Werner Nov 7 '11 at 19:20
add comment

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.

share|improve this answer
    
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 at 10:06
    
Ah point to be noted! Thank you. –  Aneesh Karthik C Jan 30 at 10:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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