
私は定理が有効になるために必要な条件を記述しようとしています。その条件は自動的に番号が付けられ、後で参照することができます (たとえば、リンクを使用して初期条件定義に戻ることができます)。
取得しようとしている形式は次のとおりです。
(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
「項目なし」の条件では、などとして印刷される同様の参照ラベルを使用する必要があります(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}