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?
5 Answers
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
.
-
Thanks, I'll try it out and get back. Maybe I'll use a different shape than a triangle though.– P.ACommented 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? Commented 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. Commented Apr 24, 2011 at 9:49
-
1If 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.ACommented Apr 24, 2011 at 11:01 -
@P.A It works for me so you need to provide an example that does not work. Commented Apr 24, 2011 at 12:13
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}
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}
-
Seems there's a couple of syntax problems here. (Feel free to remove this comment when fixed.)– badroitCommented 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$}
Commented Nov 21, 2017 at 14:12 -
-
@AndrewSwann That is an awesome solution, but there is a small typo:
\AtBeginEnvironment{#1
should be\AtBeginEnvironment{#1}
-> the final brace is missing ;-)– wmnorthCommented Nov 29, 2018 at 21:59 -
@wmnorth Yes thanks - unfortunately I can no longer edit my comment. Commented Nov 30, 2018 at 7:38
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.
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.
Use \qed right before \end{example} :
\newtheorem{example}[definition]{Example}
.
.
.
\begin{example}
5+6=11
\qed
\end{example}
-
2I believe the downvotes are because the OP specifically stated that
\qed
was not sufficient for this purpose. Commented Jan 19, 2015 at 19:57 -
@AndrewCashner: Yes, probably, but it's not necessary to downvote even more (whoever did it ;-)– user31729Commented Jan 19, 2015 at 20:08
-
1@ChristianHupfer Wasn't me. +1 to restore balance and welcome a new user. Commented Jan 19, 2015 at 20:10
-
@AndrewCashner: I did not suspect you at all ...– user31729Commented Jan 19, 2015 at 22:19