如何在单个括号中引用多个列表项,例如“(1-3)”?
例如,我有
\usepackage[shortlabels]{enumitem}
\begin{enumerate}[(1)]
\item \label{itm:1} more than 100
\item \label{itm:2} less than three
\item \label{itm:3} much less than ten
\end{enumerate}
我如何使用\ref
或类似于参考项目 1 至 3 的内容?
答案1
完全删除中间的括号可能会造成混淆,而且不容易实现。使用 可以很容易地在括号之间自动放置范围标记,同时保留括号,cleveref
而且更清晰:
\documentclass{article}
\usepackage[shortlabels]{enumitem}
\usepackage{cleveref}
\crefrangeformat{enumi}{items #3#1#4--#5#2#6}
\begin{document}
\begin{enumerate}[(1)]
\item \label{itm:1} more than 100
\item \label{itm:2} less than three
\item \label{itm:3} much less than ten
\end{enumerate}
Referencing \cref{itm:1,itm:2,itm:3}.
\Cref{itm:1,itm:2} are just two items and \cref{itm:3} is another.
\end{document}
答案2
您可以通过以下方式为项目label
指定单独的ref
enumitem
然后您就可以根据需要构建参考:
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=(\arabic*),ref=\arabic*]
\item \label{itm:1} more than 100
\item \label{itm:2} less than three
\item \label{itm:3} much less than ten
\end{enumerate}
\noindent
See (\ref{itm:1}--\ref{itm:3}).
\end{document}