
定義(\arabic
)があり、その中にはサブ定義( )の小さなリストが含まれているとします\alph
。完全な相互参照(2.3a、2.3b、...)。しかし、文脈から主な定義が明らかな場合は、短い相互参照(1つの、b、..)。
しかし、マクロを 1 つしか定義できません\thesubdefinition
。そこで質問です。1 つのカウンター (つまり、1 つの ) に複数の書式設定を関連付ける推奨される方法はありますか? 「ユーザー コード」では、完全な参照には を使用し、短い参照には を\label
使用することを想像しています。\ref
\shortref
\newcounter{subdefinition}[definition]
\def\subdef#1{\refstepcounter{subdefinition}(\alph{subdefinition}) #1}
...
\begin{definition} \label{def}
Bla bla technical stuff:
\subdef{simple axiom}\label{simple},
\subdef{complex axiom}\label{complex}.
Note that axiom~\shortref{complex} is more complex than axiom~\shortref{simple}.
\end{definition}
We will focus mostly on axiom~\shortref{complex}). % axiom b
...
Recall that axiom~\ref{complex} is very complex. % axiom 2.3b
おそらく何かをハッキングできると思いますが、これ用のパッケージがあるでしょうか?
答え1
以下を使用できますzref
:
\documentclass{article}
\usepackage{amsthm}
\usepackage[user]{zref}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\newcounter{subdefinition}[definition]
\makeatletter
\zref@newprop{subdef}{}
\zref@newprop{fulldef}{}
\zref@addprop{main}{subdef}
\zref@addprop{main}{fulldef}
\newcommand\subdef[1]{%
\refstepcounter{subdefinition}%
\zref@setcurrent{subdef}{\alph{subdefinition}}%
\zref@setcurrent{fulldef}{\thedefinition\alph{subdefinition}}%
(\alph{subdefinition})~#1%
}
\newcommand{\shortref}[1]{\zref[subdef]{#1}}
\newcommand{\fullref}[1]{\zref[fulldef]{#1}}
\makeatother
\begin{document}
\section{A definition}
\begin{definition} \label{def}
Bla bla technical stuff:
\subdef{simple axiom}\zlabel{simple},
\subdef{complex axiom}\zlabel{complex}.
Note that axiom~\shortref{complex} is more complex than axiom~\shortref{simple}.
\end{definition}
\section{A reference}
We will focus mostly on axiom~\fullref{complex}.
\end{document}
\zlabel
のラベルを設定するには を使用する必要があることに注意してください\subdef
。