Запись условий теорем с автоматической нумерацией и метками

Запись условий теорем с автоматической нумерацией и метками

Я пытаюсь написать условия, которые требуются для того, чтобы теорема была верна, так, чтобы условие автоматически нумеровалось И на него можно было ссылаться позднее (например, можно было использовать ссылку для возврата к определению начального условия).

Формат, который я пытаюсь получить, следующий:

(C1) Statement about the required process

А ссылка в документе будет такой:

Following from (C1), we have that blah.

Я пробовал что-то вроде этого:

\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}

Какие-либо предложения?

решение1

Вот возможный способ использовать элементы enumerateи сделать их subcondition, используя Conditionсчетчик в качестве родителя.

Условия «Itemless» должны использовать похожую ссылочную метку, печатаемую как и (C2)т. д. Чтобы добиться этого, нужно изменить макрос \p@Condition, чтобы сначала получить имя счетчика, а )затем добавить его.

\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}

введите описание изображения здесь

ОбновлятьВерсия с нумерацией (C1) в качестве заголовка «теорема» с окружением.

Я поместил \setlistизменения enumerate внутрь Conditionсреды, чтобы другие использования enumerateне имели «странных» меток перечисления.

\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}

Связанный контент