# End mark for unnumbered and continued examples

Consider the following MWE

\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{examplex}[theorem]{Example}
\newtheorem*{continuedex}{Example \continuedexref\space Continued}
\newtheorem*{example*}{Example}

\newenvironment{examcont}[1]
{\newcommand{\continuedexref}{\ref*{#1}}\continuedex}
{\endcontinuedex}

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

\begin{document}
\section{Foo}
\begin{example}
\label{exa:foo}
A numbered example.
\end{example}
\begin{examcont}{exa:foo}
An example continued.
\end{examcont}
\begin{example*}
An unnumbered example.
\end{example*}
\end{document}


This uses i) this answer to add an end mark to the example environment and ii) this answer to allow for for continued examples.

Currently I only have the end triangle mark for the standard example environment. I want to have the end mark for both the continued example and the star (unnumbered) example. How can I achieve this?

• I guess you want something more than adding a \hfill$\triangle$ to the end of your environment content? As in, \newenvironment{examcont}[1] {\newcommand{\continuedexref}{\ref*{#1}}\continuedex} {\hfill$\triangle$\endcontinuedex} – Steven B. Segletes Oct 8 '14 at 20:10
• @StevenB.Segletes: Sorry, I have just seen, that we have the same idea :D – user31729 Oct 8 '14 at 20:17
• @ChristianHupfer no problem at all. – Steven B. Segletes Oct 9 '14 at 0:34

The symbol must be inserted at the end of the environment, 'flushed' right, so use \hfill\myqedsymbol where \myqedsymbol is a macro wrapper for the particular symbol (\triangle in this case)

\documentclass{article}

\usepackage{amsthm}
\usepackage{hyperref}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{examplex}[theorem]{Example}
\newtheorem*{continuedex}{Example \continuedexref\space Continued}
\newtheorem*{example*}{Example}

\newcommand{\myqedsymbol}{\ensuremath{\triangle}}%

\newenvironment{examcont}[1]
{\newcommand{\continuedexref}{\ref*{#1}}\continuedex}
{\hfill\myqedsymbol\endcontinuedex}

\newenvironment{example}
{\pushQED{\qed}\renewcommand{\qedsymbol}{\myqedsymbol}\examplex}
{\popQED\endexamplex}

\begin{document}
\section{Foo}
\begin{example}
\label{exa:foo}
A numbered example.
\end{example}
\begin{examcont}{exa:foo}
An example continued.
\end{examcont}
\begin{example*}
An unnumbered example.
\end{example*}
\end{document}


# Version with qed mark for unnumbered example

The problem arises from the starred environment, so it's best to rename example* and define the example* as a wrapper environment:

\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{examplex}[theorem]{Example}
\newtheorem*{continuedex}{Example \continuedexref\space Continued}
\newtheorem*{examplestarred}{Example}

\newcommand{\myqedsymbol}{\ensuremath{\triangle}}%

\newenvironment{examcont}[1]{%
\pushQED{\qed}%
\renewcommand{\qedsymbol}{\myqedsymbol}%
\newcommand{\continuedexref}{\ref*{#1}}%
\continuedex%
}{%
\popQED%
\endcontinuedex%
}%

\newenvironment{example}{%
\pushQED{\qed}%
\renewcommand{\qedsymbol}{\myqedsymbol}%
\examplex%
}{%
\popQED%
\endexamplex%
}%

\newenvironment{example*}{%
\pushQED{\qed}%
\renewcommand{\qedsymbol}{\myqedsymbol}%
\examplestarred%
}{%
\popQED%
\endexamplestarred%
}%

\begin{document}
\section{Foo}
\begin{example}
\label{exa:foo}
A numbered example.
\end{example}
\begin{examcont}{exa:foo}
An example continued.
\end{examcont}
\begin{example*}
An unnumbered example.
\end{example*}
\end{document}


• Thanks. Do I need to load the extra ragged2e package? – petobens Oct 8 '14 at 20:40
• @petobens: No, sorry, that was my first guess-- I will remove it – user31729 Oct 8 '14 at 20:44
• The unnumbered example doesn't have an end mark. – Bernard Oct 8 '14 at 20:56
• @Bernard: Correct, I forgot the look after that issue – user31729 Oct 8 '14 at 20:58
• @Bernard: Corrected the code – user31729 Oct 8 '14 at 22:08