奇怪的是,\cref
当方程 (2) 从其范围中移除时,它不起作用。当我移除另一个方程时,它就能完美地工作。重新排序方程标签似乎不起作用。
通过使用标签来单独引用所有方程式是,,
可行的。但是,我希望文本尽可能紧凑,因此使用,,
单独的标签并明确引用每个方程式是不可取的。
我的源代码:
\documentclass[11pt, a4paper]{IEEEtran}
\usepackage{amsmath}
\usepackage{amssymb, amsfonts}
\usepackage{cleveref}
\crefformat{equation}{Eq. (#1)}
\crefrangeformat{equation}{Eqs. (#1) to (#2)}
\crefmultiformat{equation}{Eqs. (#1)}{ and (#1)}{, (#1)}{ and (#1)}
\crefrangemultiformat{equation}{Eqs. (#1) to (#2)}{}{}{}
\begin{document}
\begin{align}
y &= x_{1} + x_{2}
\label{eq:1}
\\
y &= a \thinspace x + b
\label{eq:2}
\\
e &= m \thinspace c^{2}
\label{eq:3}
\\
y^{2} + x^{2} &= r^{2}
\label{eq:4}
\\
\int\limits_{0}^{\inf} e^{-x^{2}} &= \sqrt{\pi}
\label{eq:5}
\end{align}
\rule{0pt}{1\normalbaselineskip}
Referring to the whole range of equation works
Some remarks on \cref{eq:1,eq:2,eq:3,eq:4,eq:5}
\rule{0pt}{1\normalbaselineskip}
Referring to all equations as a range except \cref{eq:2} does not work
Some remarks on \cref{eq:1,eq:3,eq:4,eq:5}
\rule{0pt}{1\normalbaselineskip}
Referring to all equations individually works
Some remarks on \cref{eq:1,,eq:3,,eq:4,,eq:5}
\end{document}
答案1
您的定义只是抛弃了单个引用或引用范围之外的所有内容,因此如果在第一个引用之后存在间隙,则不会排版其他任何内容,因为这是您cleveref
在这种情况下所要求做的。
前三种自定义格式工作正常,但如果您使用 ,它们会失效hyperref
。然而,第四种格式\crefrangemultiformat{}{}{}{}{}
不仅会丢弃链接的锚定信息,还会丢弃除第一种之外的所有交叉引用信息。
将该定义更改为
\crefrangemultiformat{equation}{#3Eqs. ((#1))#4 to #5((#2))#6}{ and #3(#1)#4 to #5(#2)#6}{, #3(#1)#4 to #5(#2)#6}{ and #3(#1)#4 to #5(#2)#6}
产生了我认为是预期的结果。
\documentclass[11pt, a4paper]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{cleveref}
\crefformat{equation}{#2Eq. (#1)#3}
\crefrangeformat{equation}{#3Eqs. (#1)#4 to #5(#2)#6}
\crefmultiformat{equation}{#2Eqs. (#1)#3}{ and #2(#1)#3}{, #2(#1)#3}{ and #2(#1)#3}
\crefrangemultiformat{equation}{#3Eqs. ((#1))#4 to #5((#2))#6}{ and #3(#1)#4 to #5(#2)#6}{, #3(#1)#4 to #5(#2)#6}{ and #3(#1)#4 to #5(#2)#6}
\begin{document}
\begin{align}
y &= x_{1} + x_{2}
\label{eq:1}
\\
y &= a \thinspace x + b
\label{eq:2}
\\
e &= m \thinspace c^{2}
\label{eq:3}
\\
y^{2} + x^{2} &= r^{2}
\label{eq:4}
\\
\int\limits_{0}^{\inf} e^{-x^{2}} &= \sqrt{\pi}
\label{eq:5}
\end{align}
Referring to the whole range of equation works.
Some remarks on \cref{eq:1,eq:2,eq:3,eq:4,eq:5}.
\bigskip
Referring to all equations as a range except \cref{eq:2} works fine when the definition doesn't throw the information away.
Some remarks on \cref{eq:1,eq:3,eq:4,eq:5}.
\bigskip
Referring to all equations individually works.
Some remarks on \cref{eq:1,,eq:3,,eq:4,,eq:5}.
\end{document}