# How can I apply a custom-defined theorem environment to nested theorems WITHOUT using a proof environment?

I'd like to combine a couple of constructions I've found on this site to create a custom-defined cases environment so that each case will:

1. be nested within a larger theorem environment;
2. end with a qedsymbol without needing a proof environment; and
3. use a custom qedsymbol consisting of the boxed case name.

That sounds like a lot, so let me make this more precise.

I'd like the general form of my document to be as shown in this MWE:

\documentclass{article}
\usepackage{amsthm,xpatch}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}

\newtheoremstyle{underline}% name
{-1.5mm}        % Space above, empty = usual value'
{}              % Space below
{}              % Body font
{\parindent}    % Indent amount (empty = no indent, \parindent = para indent)
{:}             % Punctuation after thm head
{1.5mm}         % Space after thm head: \newline = linebreak
{{\underline{\thmname{#1}\thmnumber{ #2}~\thmnote{(#3)}}}}  % Thm head spec

\theoremstyle{underline}
\newtheorem{case}{Case}

\begin{document}
\begin{thm}
Here is a theorem.
\end{thm}
\begin{proof}
Consider the following two cases:
\begin{case}
Case 1 is...
\end{case}
\begin{case}
Case 2 is...
\end{case}
As the preceding cases show, we've proven something!
\end{proof}
\end{document}


As written, that renders as follows:

What I'd like to do is to enhance this MWE by combining two separate SxE posts, namely:

• Using this solution, I want to end each instance of case with a qedsymbol without requiring the addition of \begin{proof}...\end{proof}; and
• using this solution, I want to recognize that case is nested and to change the qedsymbol mentioned previously to be boxed versions of Case 1, Case 2, etc.

The desired end result would render something like this:

. For the record, the solution of the first linked question has the form

% redefine the \@endtheorem macro
\makeatletter
\def\@endtheorem{\qed\endtrivlist\@endpefalse } % insert \qed macro
\makeatother


(note that I'm trying to use the amsthm solution), and the solution of the second linked question has the form

\makeatletter
\let\qed@empty\openbox % <--- change here, if desired
\def\@begintheorem#1#2[#3]{%
\@ifempty{#1}
{\let\thmname\@gobble}
{\let\thmname\@iden}%
\@ifempty{#2}
{\let\thmnumber\@gobble\global\let\qed@current\qed@empty}
{\let\thmnumber\@iden\xdef\qed@current{#2}}%
\@ifempty{#3}
{\let\thmnote\@gobble}
{\let\thmnote\@iden}%
}\ignorespaces
}
\renewcommand{\qedsymbol}{%
\ifx\qed@thiscurrent\qed@empty
\qed@empty
\else
\fbox{\scriptsize\qed@thiscurrent}%
\fi
}
\renewcommand{\proofname}{%
Proof%
\ifx\qed@thiscurrent\qed@empty
\else
\ of \qed@thiscurrent
\fi
}
\xpretocmd{\proof}{\let\qed@thiscurrent\qed@current}{}{}
\newenvironment{proof*}[1]
{\def\qed@thiscurrent{\ref{#1}}\proof}
{\endproof}
\makeatother


(requiring only amsthm and xpatch).

Is this possible?

• It certainly is simpler to do with ntheorem. – Bernard Apr 2 '16 at 21:46
• @Bernard - You're surely correct. However, this particular implementation will likely end up in my dissertation and my university's dissertation class conflicts infamously with a number of excellent packages. To avoid a potential conflict, I'd prefer solutions with fewer potential conflicts. – cstover Apr 2 '16 at 22:03

Here is a solution. We need

\let\mtendcase\endcase


MWE

\documentclass{article}
\usepackage{amsthm}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}

\newtheoremstyle{underline}% name
{-1.5mm}        % Space above, empty = usual value'
{}              % Space below
{}              % Body font
{\parindent}    % Indent amount (empty = no indent, \parindent = para indent)
{:}             % Punctuation after thm head
{1.5mm}         % Space after thm head: \newline = linebreak
{{\underline{\thmname{#1}\thmnumber{ #2}~\thmnote{(#3)}}}}  % Thm head spec

\theoremstyle{underline}
\newtheorem{case}{Case}
\let\mtendcase\endcase

\begin{document}
\begin{thm}
Here is a theorem.
\end{thm}
\begin{proof}
Consider the following two cases:
\begin{case}
Case 1 is...
\end{case}
\begin{case}
Case 2 is...
\end{case}
As the preceding cases show, we've proven something!
\end{proof}
\end{document}