1

I would like an example environment which is numbered according to theorems (e.g. theorem 1, example 2, theorem 3, example 4, ...) and ends with a clubsuit. I've already seen this solution, but I would rather have one which doesn't use the ntheorem package; either by creating a new environment, or by rewriting the existing one (e.g. the proof environment). I'm not particularly experienced with LaTex, so I'm asking this.

This is the code I have so I can get started. I can live with the error for now.

\documentclass{amsart}

% \usepackage[utf8]{inputenc}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}[theorem]{Example}
\newenvironment{example}{\paragraph{Example:}}{\hfill$\clubsuit$\vspace{10pt}}
% produces Error: Command \example already defined.

It mostly works. It is numbered according to theorem, and ends with a clubsuit:

\begin{example}
    First example.
\end{example}

first example

However, there are some issues, as illustrated below:

\begin{example}
    Second example.
\end{example}
Line after second example breaks it.

enter image description here This can be fixed by adding a new line as follows:

\begin{example}
    Third example.
\end{example}

A line after a newline after the third example is okay.

enter image description here But I'd rather not have to do this fix in the first place. Also, the environment doesn't work with equations.

\begin{example}
    Example ending on an equation (qedhere does not work)
    \begin{equation*}
        a = b.
    \end{equation*}
\end{example}

enter image description here Unlike the proof environment, \qedhere does not work. Similar issue goes with itemize/enumerate. In summary, I would like a minimal, non-ntheorem-based example environment, which is essentially a copy of the proof environment, but the QED symbol is replaced by a clubsuit (such that the \qedhere command or equivalent can bring the clubsuit into an ending equation). I'm sure there is a simpler solution than what I have.


Update. The following solution adapted from here is very close to what I want:

\newcommand{\newmarkedtheorem}[1]{%
  \newenvironment{#1}
    {\pushQED{\hfill$\clubsuit$}\csname inner@#1\endcsname}
    {\popQED\csname endinner@#1\endcsname}%
  \newtheorem{inner@#1}%
}
\newmarkedtheorem{example}[theorem]{Example}

However, there is still an issue with the equation and align environments.

\begin{example}
    Example ending in align environment:
    \begin{align*}
        1 + 1 + 1 &= 1 + 2\\
        &= 3.\qedhere
    \end{align*}
\end{example}

enter image description here

5
  • 3
  • @barbarabeeton it does. Thank you!
    – dTdt
    Apr 26, 2022 at 16:24
  • @barbarabeeton thanks for the link. I may have spoke too soon earlier (in terms of completely solving the problem). I'm doing some more tests with the align environment.
    – dTdt
    Apr 26, 2022 at 18:41
  • What's important in applying \qedhere is putting it in the right place. Since you always want to change the qed box to the clubsuit, you might want to define a \clubhere that resets the symbol and then goes on to do the rest of what \qedhere does, namely the change of location. (I thought that was covered in the answer I linked.) Apr 26, 2022 at 18:49
  • @barbarabeeton I'm not familiar with LaTeX syntax. How can I define \clubhere with that functionality? That might very well solve the issue I'm having right now (see update). Thank you.
    – dTdt
    Apr 26, 2022 at 18:58

1 Answer 1

2

The problem is with \pushQED{\hfill$\clubsuit$}. You really need \pushQED{\qed} or to define something else along the line of \qed.

The easiest way is to add an optional argument for the symbol to use.

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

\newcommand{\newmarkedtheorem}[2][\openbox]{%
  \newenvironment{#2}
    {\renewcommand{\qedsymbol}{#1}\pushQED{\qed}\csname inner@#2\endcsname}
    {\popQED\csname endinner@#2\endcsname}%
  \newtheorem{inner@#2}%
}

\newtheorem{theorem}{Theorem}
\newmarkedtheorem[$\clubsuit$]{example}[theorem]{Example}
\newmarkedtheorem[$\diamondsuit$]{exercise}{Exercise}

\begin{document}

\begin{example}
An example.
\end{example}

\begin{exercise}
An exercise.
\end{exercise}

\begin{example}
    Example ending in align environment:
    \begin{align*}
        1 + 1 + 1 &= 1 + 2\\
        &= 3.\qedhere
    \end{align*}
\end{example}

\end{document}

enter image description here

Using no optional argument would default to the standard \openbox.

You must log in to answer this question.

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