# Writing theorem conditions with automatic numbering and labels

I'm trying to write conditions that are required for a theorem to be valid such that the condition is automatically numbered AND is able to be referenced at a later time (e.g. a link can be used to go back to the initial condition definition.)

The format I am trying to obtain is:

(C1) Statement about the required process


And the in document reference would be:

Following from (C1), we have that blah.


I've tried something along the lines of:

\documentclass{article}
\usepackage{cleveref}

\usepackage{amsthm}

% Define new theorem environment that works only with conditions
\newtheorem{Condition}{C}

\crefname{Condition}{C}{C} % singular and plural forms of label

\begin{document}

% Attempt 1
\begin{Condition}
\begin{enumerate}
\item Statement about the required process. \label{cond:test}
\item Next statement about the required process. \label{cond:test2}
\end{enumerate}
\end{Condition}

% Attempt 2
\begin{Condition}
Statement about the required process. \label{cond:test3}
\end{Condition}

(C\ref{cond:test}, \ref{cond:test2}, \ref{cond:test3}

\end{document}


Any suggestions?

• Your 'reference' system is not yet well-designed – user31729 Jan 30 '17 at 21:51
• Using \Cref for cond:test or cond:test2 it will print Item because that's the counter connected to the label, not Condition! – user31729 Jan 30 '17 at 22:11

Here is a possible way, to use the items of enumerate and make them a subcondition, using the Condition counter as a parent.

'Itemless' conditions should use a similar reference label, being printed as (C2) etc. In order to achieve this, one has to change the \p@Condition macro, in order to grab the counter name first and append the ) afterwards.

\documentclass{article}
\usepackage{amsthm}
\usepackage{enumitem}

\newtheorem{Condition}{C}

\usepackage{hyperref}
\usepackage{cleveref}

\setlist[enumerate,1]{leftmargin={40pt},label=(C\theCondition.\arabic*),ref=(C\theCondition.\arabic*),before={\leavevmode}}

\makeatletter
\def\@grabconditioncounter\csname #1\endcsname{%
(C\csname#1\endcsname)%
}

\renewcommand\p@Condition{\@grabconditioncounter}

\makeatother

\begin{document}

\begin{Condition}
\begin{enumerate}
\item Statement about the required process. \label{cond:test}

\item Next statement about the required process. \label{cond:test2}
\end{enumerate}
\end{Condition}

% Attempt 2
\begin{Condition}
Statement about the required process. \label{cond:test3}
\end{Condition}

Following from \ref{cond:test}, we have that\dots, but \ref{cond:test2} and \ref{cond:test3} are important also.

\end{document}


Update A version with (C1) numbering as 'theorem' head with an environment.

I've put the \setlist changes of enumerate inside of the Condition environment such that other usages of enumerate will not have the 'strange' enumeration labels then.

\documentclass{article}
\usepackage{enumitem}

\newcounter{Condition}
\newenvironment{Condition}{%
\setlist[enumerate,1]{font={\itshape},leftmargin={40pt},label=(C\theCondition.\arabic*),ref=(C\theCondition.\arabic*)}%,before={\leavevmode}}
\parindent=0em
\refstepcounter{Condition}%
\textbf{(C\theCondition)}

%Explicit newline above
}{%
}

\usepackage{hyperref}
\usepackage{cleveref}

\makeatletter
\def\@grabconditioncounter\csname #1\endcsname{%
(C\csname#1\endcsname)%
}
\renewcommand\p@Condition{\@grabconditioncounter}
\makeatother

\begin{document}
\begin{Condition}
\begin{enumerate}
\item Statement about the required process. \label{cond:test}

\item Next statement about the required process. \label{cond:test2}
\end{enumerate}
\end{Condition}

% Attempt 2
\begin{Condition}
Statement about the required process. \label{cond:test3}
\end{Condition}

Following from \ref{cond:test}, we have that\dots, but \ref{cond:test2} and \ref{cond:test3} are important also.

\begin{enumerate}
\item A
\item B
\end{enumerate}

\end{document}

• Exactly what I needed! Thanks. I appreciate it greatly. – coatless Jan 30 '17 at 23:04
• @coatless: You're welcome. Nevertheless, I think you should think about the precise numbering in future documents – user31729 Jan 30 '17 at 23:05
• Could you clarify "Precise numbering?" Also, is there an easy way to get the definition label updated to (C1) vs. the present C 1? – coatless Jan 30 '17 at 23:08
• @coatless: The precise numbering means how sub conditions are numbered (your \items, for example). The (C1) is more difficult since you're using a theorem (unnecessarily, in my point of view, a normal environment would be easier to change) – user31729 Jan 30 '17 at 23:12
• @coatless: \newtheoremstyle is a possible option. I've added a non-theorem approach – user31729 Jan 30 '17 at 23:17