Escrevendo condições de teorema com numeração e rótulos automáticos

Escrevendo condições de teorema com numeração e rótulos automáticos

Estou tentando escrever condições necessárias para que um teorema seja válido, de modo que a condição seja automaticamente numerada E possa ser referenciada posteriormente (por exemplo, um link pode ser usado para voltar à definição da condição inicial).

O formato que estou tentando obter é:

(C1) Statement about the required process

E a referência no documento seria:

Following from (C1), we have that blah.

Eu tentei algo como:

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

Alguma sugestão?

Responder1

Aqui está uma maneira possível de usar os itens de enumeratee torná-los a subcondition, usando o Conditioncontador como pai.

As condições 'sem item' devem usar um rótulo de referência semelhante, sendo impressa como (C2)etc. Para conseguir isso, é necessário alterar a \p@Conditionmacro, para pegar primeiro o nome do contador e anexá-lo )depois.

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

insira a descrição da imagem aqui

AtualizarUma versão com numeração (C1) como cabeçalho de 'teorema' com um ambiente.

Coloquei as \setlistalterações de enumerate dentro do Conditionambiente de forma que outros usos de enumeratenão tenham os rótulos de enumeração 'estranhos'.

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

informação relacionada