12

I have a theorem environment I've made called "ex" (using the theoremstyle "definition"), which I use for examples in a book document class. I like that I can number the examples, but I want a proof symbol to occur at the end of every example.

I have something that looks like:

\newtheorem{ex}{Example}[section]  
\renewenvironment{ex}{}{\qed \\}

However, I want "Example 1.1.1" to show up when I call \begin{ex}. How do I change the environment so that there is no change to the beginning definition, but changes the ending definition to the qed symbol?

Here is a MWE:

\documentclass{book}
\usepackage{amssymb, amsmath, amsthm}
\newtheorem{ex}{Example}[chapter]
\begin{document}
\begin{ex}
This is my example
\end{ex}
\end{document}
13

You can change just the end environment via:

\let\Oldendex\endex%
\def\endex{\qed\Oldendex}%

Here is a before and after:

enter image description here enter image description here

Code:

\documentclass{book}
\usepackage{amssymb, amsmath, amsthm}

\newtheorem{ex}{Example}[chapter]

\let\Oldendex\endex%
\def\endex{\qed\Oldendex}%

\begin{document}
\begin{ex}
This is my example
\end{ex}
\end{document}

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.