
我有一個帶有參數的多個條件的列表,並且我想在條件的標記中明確包含該參數。不過,我還想在下文中引用每個條件(參數固定)的定義。 (這有點難以描述,但是如果您查看下面的程式碼,應該會清楚我的意思。)
這可以使用 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}
n在標籤中但不在參考文獻中。這允許您透過主數字並添加您自己的下標來引用方程式。
現在,您可以使用指令 定義帶有兩個參數(方程式和下標)的單獨引用命令\hyperref[target label]{link text}
。
\ref
為了避免出現雙連結框,您可以停用使用星形形式 ( )的鏈接\ref*
,並為組合標籤\hyperref
建立連結框(或帶有 的顏色連結)。\usepackage[colorlinks]{hyperref}
微量元素:
\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}
結果: