자동 번호 매기기 및 레이블을 사용하여 정리 조건 작성

자동 번호 매기기 및 레이블을 사용하여 정리 조건 작성

조건에 자동으로 번호가 매겨지고 나중에 참조될 수 있도록 정리가 유효하기 위해 필요한 조건을 작성하려고 합니다(예: 초기 조건 정의로 돌아가는 데 링크를 사용할 수 있음).

내가 얻으려는 형식은 다음과 같습니다.

(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하고 항목을 만드는 가능한 방법은 다음과 같습니다 .subconditionCondition

'항목 없음' 조건은 유사한 참조 라벨을 사용하여 인쇄되어야 합니다 (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내부에 열거의 변경 사항을 넣었습니다 .Conditionenumerate

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

관련 정보