下面的代码生成正确的输出。但是,我想知道如何才能在特定情况下暂时用“or”替换“and”的每个实例\cref
。我特意加入了xcolor
and,hyperref
因为我希望该解决方案与超链接兼容。
\documentclass[reqno]{amsart}
\usepackage[x11names]{xcolor}
\usepackage{hyperref}
\hypersetup{linkcolor=DodgerBlue3, colorlinks=true}
\usepackage[nameinlink]{cleveref}
\crefformat{equation}{Eq. #2(#1)#3}
\crefrangeformat{equation}{Eqs. #3(#1)#4 to #5(#2)#6}
\crefmultiformat{equation}{Eqs. #2(#1)#3}{ and #2(#1)#3}{, #2(#1)#3}{ and #2(#1)#3}
\crefrangemultiformat{equation}{Eqs. #3(#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}
e &= m c^{2}
\label{eq1}
\\
r &= \sqrt{a^{2} + b^{2}}
\label{eq2}
\\
R_{eq} &= \left( \frac{1}{R_{1}} + \frac{1}{R_{2}} \right)^{-1}
\label{eq3}
\\
V &= R I
\label{eq4}
\\
S &= V I^{*}
\label{eq5}
\\
P &= V I \cos(\theta)
\label{eq6}
\\
Q &= V I \cos(\theta)
\label{eq7}
\end{align}
\cref{eq1,eq3}
\cref{eq1,eq2,eq3,eq6,eq7}
\end{document}
答案1
使连词依赖于宏:
\documentclass[reqno]{amsart}
\usepackage[x11names]{xcolor}
\usepackage{hyperref}
\hypersetup{linkcolor=DodgerBlue3, colorlinks=true}
\usepackage[nameinlink]{cleveref}
\crefformat{equation}{Eq. #2(#1)#3}
\crefrangeformat{equation}{Eqs. #3(#1)#4 to #5(#2)#6}
\crefmultiformat{equation}
{Eqs. #2(#1)#3}
{ \andor\ #2(#1)#3}
{, #2(#1)#3}
{ \andor\ #2(#1)#3}
\crefrangemultiformat{equation}
{Eqs. #3(#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}
\newcommand{\andor}{and}
\newcommand{\crefor}[1]{\begingroup\renewcommand{\andor}{or}\cref{#1}\endgroup}
\begin{document}
\begin{align}
e &= m c^{2}
\label{eq1}
\\
r &= \sqrt{a^{2} + b^{2}}
\label{eq2}
\\
R_{eq} &= \left( \frac{1}{R_{1}} + \frac{1}{R_{2}} \right)^{-1}
\label{eq3}
\\
V &= R I
\label{eq4}
\\
S &= V I^{*}
\label{eq5}
\\
P &= V I \cos(\theta)
\label{eq6}
\\
Q &= V I \cos(\theta)
\label{eq7}
\end{align}
\cref{eq1,eq3}
\cref{eq1,eq2,eq3,eq6,eq7}
\crefor{eq1,eq2,eq3,eq6,eq7}
\end{document}
答案2
我不是专家,但是如何使用该\Cref
功能来定义不同的东西呢?例如:
\documentclass[reqno]{amsart}
\usepackage[x11names]{xcolor}
\usepackage{hyperref}
\hypersetup{linkcolor=DodgerBlue3, colorlinks=true}
\usepackage[nameinlink]{cleveref}
\crefformat{equation}{Eq. #2(#1)#3}
\crefrangeformat{equation}{Eqs. #3(#1)#4 to #5(#2)#6}
\crefmultiformat{equation}{Eqs. #2(#1)#3}{ and #2(#1)#3}{, #2(#1)#3}{ and #2(#1)#3}
\crefmultiformat{equation}{Eqs. #2(#1)#3}{ and #2(#1)#3}{, #2(#1)#3}{ and #2(#1)#3}
\Crefmultiformat{equation}{Eqs. #2(#1)#3}{ and #2(#1)#3}{, #2(#1)#3}{ or #2(#1)#3}
\crefrangemultiformat{equation}{Eqs. #3(#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}
e &= m c^{2}
\label{eq1}
\\
r &= \sqrt{a^{2} + b^{2}}
\label{eq2}
\\
R_{eq} &= \left( \frac{1}{R_{1}} + \frac{1}{R_{2}} \right)^{-1}
\label{eq3}
\\
V &= R I
\label{eq4}
\\
S &= V I^{*}
\label{eq5}
\\
P &= V I \cos(\theta)
\label{eq6}
\\
Q &= V I \cos(\theta)
\label{eq7}
\end{align}
\cref{eq1,eq3}
\cref{eq1,eq2,eq3,eq6,eq7}
\Cref{eq1,eq2,eq3,eq6,eq7}
\end{document}