[Tex/LaTex] How to make all the theorem-alike environments have an ending symbol

symbolstheorems

I have a question about making an ending symbol.

It is a LaTex-default that every proof environment has an ending symbol. I want to make every theorem-alike environment such as the example environment have also an ending symbol. But how to manually set this up? Specifically, I want to make all these environments ended by a square symbol.

\newtheorem{thm}{Theorem}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{pro}[thm]{Proposition}
\newtheorem{assump}{Assumption}
\newtheorem{axiom}{Axiom}
\newtheorem*{conj}{Conjecture}
\theoremstyle{definition}
\newtheorem{defi}[thm]{Definition}
\newtheorem{exam}{Example}
\newtheorem{exer}{Exercise}
\newtheorem*{rem}{Remark}
\newtheorem*{notation}{Notation}
\newtheorem*{note}{Note}

I am looking for, with gratitude, a comprehensive setup.

Best Answer

Asssume you are using \newtheorem from amsthm. Here \newtheorem defines new theorem-alike environments and ends them by \@endtheorem. The later is originally defined as \def\@endtheorem{\endtrivlist\@endpefalse } and you can insert your ending symbol here.

\documentclass{article}
\usepackage{amsthm}
\usepackage{manfnt}
\makeatletter
    \def\@endtheorem{\hfill\dbend\endtrivlist\@endpefalse }
\makeatother
\begin{document}
    \newtheorem{thm}{Theorem}
    \begin{thm}
        Zigzagging is dangerous.
    \end{thm}
\end{document}

(Ideas come form here)

Caution!

As mentioned by egreg and barbara beeton below, this construction is not perfect. Neither it is as good as the proof environment from amsmath. One of the fatal defects is

if the text happens to end near the right margin, the symbol will be flush left, not flush right.

Therefore if you want an ending symbol exactly as the one from proof, you need either (see egreg's answer for details)

  • deal with glues and penalties.

  • pack your theorem-alike environment by adding \pushQED{your symbol} before and \popQED after. It is amsthm provides these two commands which take care of everything. (You can even use \qedhere).

Related Question