42

What is the etiquette to denote the end of an example or remark? For proofs, it's the QED symbol (white box). I know it's not necessary for everyone, but I would like to use it to break up the text a little. What should I use? A circle or filled box or what?

2
  • Why not the same QED symbol?
    – Emre
    Apr 23, 2011 at 16:18
  • 9
    I already use it for proofs so I don't want to use it for anything else.
    – P.A
    Apr 24, 2011 at 10:33

5 Answers 5

19

I think this is totally a matter of personal style. If you are using \qed already you could use a similar symbol like \triangle.

Whatever you do, don't just use \hfil$\triangle$ because this does not work when your example fills the last line completely. Here is a definition of \demo that uses the flexible \xqed:

\documentclass{minimal}
\usepackage[utf8]{inputenc}

\newcommand\xqed[1]{%
  \leavevmode\unskip\penalty9999 \hbox{}\nobreak\hfill
  \quad\hbox{#1}}
\newcommand\demo{\xqed{$\triangle$}}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
\demo    
\end{document}

The manfnt font also provides a filled triangle pointing to the right. After declaring \font\manual=manfnt you can use \manual\char'170.

Two different triangles

8
  • Thanks, I'll try it out and get back. Maybe I'll use a different shape than a triangle though.
    – P.A
    Apr 24, 2011 at 9:17
  • The triangle pointing the right looks as though it is a link to somewhere else. What specifically is it supposed to denote? Apr 24, 2011 at 9:34
  • 1
    @brannerchinese I had no specific meaning in mind, it is just one of the lesser known symbols in the standard fonts. I agree that it suggests a continuation and as such is not appropriate for denoting the end of a section. Apr 24, 2011 at 9:49
  • 1
    If I have an equation as the last line in my example, unfortunately the character appears a few lines before my last line. Is there a way to change that? I tried putting the \demo before the end of equation, but that makes the symbol not align properly.
    – P.A
    Apr 24, 2011 at 11:01
  • @P.A It works for me so you need to provide an example that does not work. Apr 24, 2011 at 12:13
43

Try the following indirect method (requires amsthm):

\newtheorem{example}{Example}
\AtBeginEnvironment{example}{%
  \pushQED{\qed}\renewcommand{\qedsymbol}{$\triangle$}%
}
\AtEndEnvironment{example}{\popQED\endexample}

Full example

\documentclass{article}
\usepackage{amsmath,amsthm}

% some setup
%
% maybe change here the default symbol
% \renewcommand{\qedsymbol}{...}
%
\NewCommandCopy{\proofqedsymbol}{\qedsymbol}% save the default
\newcommand{\exampleqedsymbol}{$\triangle$}% for end of examples

% ensure that proof has the standard symbol
\AtBeginEnvironment{proof}{\renewcommand{\qedsymbol}{\proofqedsymbol}}

% define an environment for examples
\theoremstyle{definition}

\newtheorem{example}{Example}
\AtBeginEnvironment{example}{%
  \pushQED{\qed}\renewcommand{\qedsymbol}{$\triangle$}%
}
\AtEndEnvironment{example}{\popQED\endexample}

\begin{document}

\begin{example}
This has only text.
\end{example}

\begin{example}
This has text but also a proof inside it.
\begin{proof}
This is the proof of the above claim.
\end{proof}
And now the example is over.
\end{example}

\begin{example}
This has also a display at the end:
\begin{align*}
f(x) &= \bigl( g(x) \bigr) \\
h(x) &= \bigl( r(x) \bigr).\qedhere
\end{align*}
\end{example}

\end{document}

enter image description here

LaTeX has now incorporated \AtBeginEnvironment and \AtEndEnvironment that used to be only available with etoolbox.

Original answer

Try the following indirect method (requires amsthm):

\newtheorem{examplex}{Example}
\newenvironment{example}
  {\pushQED{\qed}\renewcommand{\qedsymbol}{$\triangle$}\examplex}
  {\popQED\endexamplex}

In this way also \qedhere works exactly like in proof.

Full example.

\documentclass{article}
\usepackage{amsmath,amsthm}

\theoremstyle{definition}
\newtheorem{examplex}{Example}
\newenvironment{example}
  {\pushQED{\qed}\renewcommand{\qedsymbol}{$\triangle$}\examplex}
  {\popQED\endexamplex}

\begin{document}

\begin{example}
This has only text.
\end{example}

\begin{example}
This has also a display at the end:
\begin{align*}
f(x) &= \bigl( g(x) \bigr) \\
h(x) &= \bigl( r(x) \bigr).\qedhere
\end{align*}
\end{example}

\end{document}
11
  • Seems there's a couple of syntax problems here. (Feel free to remove this comment when fixed.)
    – badroit
    Jul 17, 2012 at 16:35
  • Nice. With etoolbox you can define a command to patch a previously declared theorem type: \newcommand{\addQEDstyle}[2]{\AtBeginEnvironment{#1{\pushQED{\qed}\renewcommand{\qedsymbol}{#2}}\AtEndEnvironment{#1}{\popQED}}. Call as \addQEDstyle{example}{$\triangle$} Nov 21, 2017 at 14:12
  • @AndrewSwann That could be an alternative way.
    – egreg
    Nov 21, 2017 at 14:19
  • @AndrewSwann That is an awesome solution, but there is a small typo: \AtBeginEnvironment{#1 should be \AtBeginEnvironment{#1} -> the final brace is missing ;-)
    – wmnorth
    Nov 29, 2018 at 21:59
  • @wmnorth Yes thanks - unfortunately I can no longer edit my comment. Nov 30, 2018 at 7:38
10

The very useful thmtools package has a key for defining the qed-symbol. For example, I use the following in my documents:

\usepackage{amsthm,thmtools}
\theoremstyle{remark}
\declaretheorem[name=Example,qed={\lower-0.3ex\hbox{$◃$}}]{Ex}

...

\begin{Ex}
  The numbers 2, 3 and 5 are all prime.
\end{Ex}

(I use unicode-math to be able to use the ◃ symbol directly. Just replace it by whatever symbol you like, e.g. \triangleleft.)

Everything is set up correctly so that you can use \qedhere like in a standard amsthm proof environment.

3

Maybe you’ll like to use the {leftbar}-environment?

\documentclass{minimal}
\usepackage{framed}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
\begin{leftbar}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
\end{leftbar}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
\end{document}

If you like it I can show an extended example with a colored bar, no indention of first line an support for floating objects in the environment.

0
0

Use \qed right before \end{example} :

\newtheorem{example}[definition]{Example}
.
.
.
\begin{example}
5+6=11
\qed
\end{example}
4
  • 2
    I believe the downvotes are because the OP specifically stated that \qed was not sufficient for this purpose. Jan 19, 2015 at 19:57
  • @AndrewCashner: Yes, probably, but it's not necessary to downvote even more (whoever did it ;-)
    – user31729
    Jan 19, 2015 at 20:08
  • 1
    @ChristianHupfer Wasn't me. +1 to restore balance and welcome a new user. Jan 19, 2015 at 20:10
  • @AndrewCashner: I did not suspect you at all ...
    – user31729
    Jan 19, 2015 at 22:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .