# Creating an example environment structured exactly like amsthm's proof environment

I want to create an environment for examples that is structured exactly like the \begin{proof}...\end{proof} environment, i.e. starting with an italic "Example.", continuing in the same line and ending with a particular symbol to the far right, e.g. \clubsuit.

Edit: I am using amsthm package.

How do I do that, i.e. what is the code to be inserted at the beginning?

• you could clone the proof environment, or you might get some help from this answer: Indicator at end of theorem. – barbara beeton Dec 2 '13 at 17:55
• Hi, I do not know what it means to "clone" an environment. I have tried an analogous application of the solution provided in the thread you posted but that doesn't work, because apparently the commands \proofstyle and \newproof do not exist. I am sorry, I'm a greenhorn when it comes to things like defining my own stuff. :( – Holomorphic Dec 2 '13 at 18:25
• I guess the ntheorem and thmtools packages can help a lot. They are a lot more flexible than amsthm. Could you indicate whether it is an option for you to use another package, instead of amsthm? – jmc Dec 2 '13 at 18:27
• Do you need to number the examples? – egreg Dec 2 '13 at 18:52
• Hi egreg, no that is not necessary. Just as simple as I described above. – Holomorphic Dec 2 '13 at 18:52

this example illustrates what i meant by "cloning" the amsthm proof environment. it retains the ability to use \qedhere to "move the end-symbol up" when the environment ends with a list or display math.

\documentclass{article}
\usepackage{amsthm}

\makeatletter
\providecommand{\examplesymbol}{\ensuremath\clubsuit}
\newenvironment{example}[1][\examplename]{\par
\pushQED{\qed}%
\normalfont \topsep6\p@\@plus6\p@\relax
\begingroup
\let\qedsymbol\examplesymbol
\trivlist

\item[\hskip\labelsep
\itshape
}{%
\popQED\endtrivlist\@endpefalse
\endgroup
}
\providecommand{\examplename}{Example}
\makeatother

\begin{document}

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

\begin{example}
This is an example.  It looks like a proof.
\end{example}

\begin{example}
This example ends with a list.
\begin{itemize}
\item item 1;
\item item 2. \qedhere
\end{itemize}
\end{example}

\begin{example}
This example ends with display math.
$x + y = z \qedhere$
\end{example}

\begin{proof}
Another proof
\end{proof}

\end{document}


there are other ways to do this, but they are manual. one such uses the "optional header" feature of the proof environment, and resets the end-symbol just before it is used.

\begin{proof}[Example]
[...]
\let\qedsymbol\examplesymbol
\end{proof}


if \qedhere is needed, precede it directly by the \let\qedsymbol substitution.