
パラメータ付きの条件のリストがいくつかあり、条件のタグにパラメータを明示的に含めたいと考えています。ただし、テキストの後半で各条件の定義 (パラメータを固定) も参照したいと思います。(説明するのは少し難しいですが、以下のコードを見れば、私の言っていることがよくわかると思います。)
これは enumitem (または互換性のある他のパッケージ) を使用して実現できますか?
ムエ:
\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{enumitem}
\newtheorem*{theorem}{Theorem}
\begin{document}
Consider the following conditions:
\begin{enumerate}[label=(\roman{*})$_n$]
\item
\label{item:first_condition}
Some condition
\item
\label{item:second_condition}
Some other conditon.
\end{enumerate}
How I would imagine I could type it:
\begin{theorem}
\ref{item:first_condition}[7] holds.
\end{theorem}
\begin{theorem}
If \ref{item:second_condition}[n] holds, then \ref{item:first_condition}[n+2] holds.
\end{theorem}
How I would like it to look like:
\begin{theorem}
(i)$_7$ holds.
\end{theorem}
\begin{theorem}
If (ii)$_n$ holds, then (i)$_{n+2}$ holds.
\end{theorem}
\end{document}
答え1
ref
enumitemでは、label
と のref
キーの両方を使用して、ラベルと出力を別々に設定できます\begin{enumerate}
。これを使用して、んラベルにはありますが、参照には含まれていません。これにより、メインの番号と独自の下付き文字を追加して方程式を参照できます。
これで、 コマンドを使用して、方程式と下付き文字の 2 つの引数を持つ別の参照コマンドを定義できるようになりました\hyperref[target label]{link text}
。
\ref
二重リンク ボックスを回避するには、星形 ( ) を使用してリンクを無効にし\ref*
、結合されたラベルの\hyperref
リンク ボックス (または を使用したカラーリンク) を作成します。\usepackage[colorlinks]{hyperref}
MWE:
\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{enumitem}
\newcommand{\nref}[2]{\hyperref[#1]{\ref*{#1}$_{#2}$}}
\newtheorem*{theorem}{Theorem}
\begin{document}
Consider the following conditions:
\begin{enumerate}[label=(\roman{*})$_n$,ref=(\roman*)]
\item
\label{item:first_condition}
Some condition
\item
\label{item:second_condition}
Some other conditon.
\end{enumerate}
How I would imagine I could type it:
\begin{theorem}
\nref{item:first_condition}{7} holds.
\end{theorem}
\begin{theorem}
If \nref{item:second_condition}{n} holds, then \nref{item:first_condition}{n+2} holds.
\end{theorem}
How I would like it to look like:
\begin{theorem}
(i)$_7$ holds.
\end{theorem}
\begin{theorem}
If (ii)$_n$ holds, then (i)$_{n+2}$ holds.
\end{theorem}
\end{document}
結果: