Intelligently Numbering "remarks" only when multiple are made

The following example patches \@thm that is defined by amsthm to remove the number, if there is only one entity.

If the theorem entity has reached number 2, then there are multiple items and a label is written to the .aux file using the theorem name and number as key.

In the next LaTeX run, the existence of this key is checked for the first item and the number is suppressed, if the label exists and there are multiple items.

\documentclass{article}

\usepackage{amsthm}
\newtheorem{thm}{Theorem}
\theoremstyle{remark}
\newtheorem{rmk}{Remark}[thm]

\usepackage{etoolbox}
\usepackage{zref-base}
\makeatletter
\patchcmd\@thm{%
  \refstepcounter{#2}%
  \def\@tempa{\@oparg{\@begintheorem{#3}{\csname the#2\endcsname}}[]}%
}{%
  \refstepcounter{#2}%
  \def\@tempa{\@oparg{\@begintheorem{#3}{\csname the#2\endcsname}}[]}%
  % \in@{,#2,}{,...,}\ifin@...\fi select the theorems for this patch
  \in@{,#2,}{,rmk,}% list of theorems with "intelligent numbering"
  \ifin@
    \ifnum\value{#2}=2 %
      \if@filesw
        \zref@wrapper@immediate{%
          \zref@labelbyprops{IntNumTheo.#2@\csname the#2\endcsname}{}%
        }%
      \fi
    \fi
    \ifnum\value{#2}=1 %
      \stepcounter{#2}%
      \zref@ifrefundefined{IntNumTheo.#2@\csname the#2\endcsname}{%
        \def\@tempa{\@oparg{\@begintheorem{#3}{}}[]}%
      }{}%
      \addtocounter{#2}{-1}%
    \fi
  \fi
}{}{\errmessage{Patching \noexpand\@thm failed}}
\makeatother

\begin{document}
\begin{thm}
Lorem ipsum.
\end{thm}

\begin{rmk} % only one remark made, so don't number it
It is Latin for ``I have boring examples''.
\end{rmk}

\begin{thm}
We see that $\pi$ is an interesting number.
\end{thm}

\begin{rmk} % Multiple remarks require numbering
It's the ratio of the circumference to the diameter of a circle.
\end{rmk}
\begin{rmk}
It's also used when I do my taxes.
\end{rmk}
% snip
\end{document}

Result


There exists an unofficial package named corollaries exactly for such a case. I've been using it for more than a year. It should soon be proposed on CTAN, but author doesn't have much time to finish the doc in English. For the moment the documentation is in French (1½ page only).

It defines three new commands, newcorollary , and for arbitrary counters (previously defined with \newcounter): DeclareCorollaryCounter and \AddToCorollaryReset. In your case, you should just write, supposing you also have a prop environment:

\newcorollary{rmk}{Remark}[thm,prop]

This defines a rmk counter which 1) is set to 0 each time the thm OR prop counter changes; 2) is not displayed for a lonely remark.

If you would use the ntheorem package, there are also \newframedcorollary and newshadedcorollary commands.

Here is an excerpt from the doc:

enter image description here

Translation of the introductory paragraph for non-French speaking readers:

The corollaries package aims at allowing automatic numbering of corollaries in the style of, for instance, Bourbaki's mathematics treatise — in other words, when a single corollary follows a theorem or a proposition, it is not numbered whereas if there are several ones, each has its number. Here is an example:

You can download it from this thread on the french help/forum site mathematex.net. If you're interested, be careful to download version 1.2.