
Ich versuche, Bedingungen zu schreiben, die für die Gültigkeit eines Theorems erforderlich sind, sodass die Bedingung automatisch nummeriert wird UND zu einem späteren Zeitpunkt referenziert werden kann (z. B. kann ein Link verwendet werden, um zur ursprünglichen Bedingungsdefinition zurückzukehren).
Das Format, das ich zu erhalten versuche, ist:
(C1) Statement about the required process
Und die Referenz im Dokument wäre:
Following from (C1), we have that blah.
Ich habe so etwas versucht:
\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}
Irgendwelche Vorschläge?
Antwort1
Dies ist eine Möglichkeit, die Elemente von zu verwenden enumerate
und sie zu einem zu machen subcondition
, wobei der Condition
Zähler als übergeordnetes Element verwendet wird.
Bei „Artikellosen“ Bedingungen sollte ein ähnliches Referenzlabel verwendet werden, das gedruckt wird als (C2)
usw. Um dies zu erreichen, muss das \p@Condition
Makro so geändert werden, dass zuerst der Zählername erfasst und )
anschließend angehängt wird.
\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}
AktualisierenEine Version mit (C1)-Nummerierung als „Theorem“-Kopf mit Umgebung.
Ich habe die \setlist
Änderungen von „enumerate“ in die Condition
Umgebung eingefügt, sodass andere Verwendungen enumerate
dann nicht die „seltsamen“ Aufzählungsbezeichnungen haben.
\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}