1

I'm looking for a command to automate a conditions' tags so that when I move them around I don't get crazy with reworking numbering. I tried to do using cleveref functionality, but I couldn't find a solution

I mean command like \cond{label} that when used like this

\begin{thm}\label{thm:1}
Suppose one (or both) of the following hold:
\cond{cnd:a}  the earth is flat;\\
\cond{cnd:b}  the sun is squared\\
if you believe it, you are not a scientist.
\end{thm}

Conditions \cref{cnd:a} and \cref{cnd:b} in  \cref{thm:1} are pretty stupid

would produce this output

enter image description here

1 Answer 1

1

In order to create cross-references to numbered objects such as "conditions", it's best to create a counter that's incremented each time a condition is inserted. This may be done smoothly with the help of the enumitem package and its \newlist and \setlist macros.

enter image description here

\documentclass{article}
\usepackage{amsthm,enumitem}
\usepackage[noabbrev,capitalize]{cleveref}

\newtheorem{thm}{Theorem}
\newlist{condenum}{enumerate}{1} % create a counter called 'condenumi'
\setlist[condenum,1]{label=\upshape(C\arabic*),nosep} % define appearance of labels
\crefname{condenumi}{condition}{conditions} % name associated with conditions

\begin{document}
\begin{thm}\label{thm:1}
Suppose one (or both) of the following hold:
\begin{condenum} % start a special enumerated list
\item \label{cnd:a}  The earth is flat.
\item \label{cnd:b}  The sun is a square.
\end{condenum}
If you believe it, you are not a scientist.
\end{thm}

\noindent
\Cref{cnd:a,cnd:b} in \cref{thm:1} are pretty stupid.
\end{document}
3
  • 1
    this is brilliant! Jul 14, 2021 at 6:26
  • @PinkCollins - You're most welcome! Just a quick follow-up/addendum: If your document has, say, 2 theorem-like environments with 3 enumerated conditions each, and if you want the conditions to have distinct "(Cx)" numbers, you may create distinct condition numbers by using \begin{condenum}[start=4] in the second theorem and \begin{condenum}[start=7] in the third theorem.
    – Mico
    Jul 14, 2021 at 6:48
  • Thanks for this, but usually conditions are stated in a way that they follow a sequence C1, C2,.... Going through the enuitem manual I could get this using the resume option in your solution here \setlist[condenum,1]{label=\upshape(C\arabic*),nosep, resume} Jul 14, 2021 at 13:33

You must log in to answer this question.

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