简单问题:有没有简单的方法可以cleveref
使用牛津逗号?
\documentclass{article}
\usepackage[standard]{ntheorem}
\usepackage{cleveref}
\begin{document}
\begin{proposition}\label{thm:roses}
Roses are red.
\end{proposition}
\begin{proposition}\label{thm:violets}
Violets are blue.
\end{proposition}
\begin{proposition}
42.
\end{proposition}
\begin{proposition} \label{thm:orchids}
Orchids are orchid.
\end{proposition}
\begin{theorem}
There exist flowers in at least three different colors.
\end{theorem}
\begin{proof}
Immediate from \cref{thm:roses,thm:violets,thm:orchids}.
\end{proof}
\end{document}
应该说“命题1、2和4”。
答案1
如果你定义这个新命令
\newcommand{\creflastconjunction}{, and\nobreakspace}
无论你在哪里使用多个这样的引用,你都会看到牛津逗号。
梅威瑟:
\documentclass{article}
\usepackage[standard]{ntheorem}
\usepackage{cleveref}
\newcommand{\creflastconjunction}{, and\nobreakspace}
\begin{document}
\begin{proposition}\label{thm:roses}
Roses are red.
\end{proposition}
\begin{proposition}\label{thm:violets}
Violets are blue.
\end{proposition}
\begin{proposition}
42.
\end{proposition}
\begin{proposition} \label{thm:orchids}
Orchids are orchid.
\end{proposition}
\begin{theorem}
There exist flowers in at least three different colors.
\end{theorem}
\begin{proof}
Immediate from \cref{thm:roses,thm:violets,thm:orchids}.
\end{proof}
\end{document}
输出:
附录
如果您想知道为什么必须使用\newcommand
而不是renewcommand
,这就是原因。
cleveref
在文档开头定义了很多取决于语言的命令。如果您不指定任何语言,english
则会加载。这是的相关部分cleveref.sty
:
\DeclareOption{english}{%
\AtBeginDocument{%
....
\def\creflastconjunction@preamble{ and\nobreakspace}%
....
此外,您还可以找到以下几行
\AtBeginDocument{%
....
\@ifundefined{creflastconjunction}{%
\let\creflastconjunction\creflastconjunction@preamble%
}{%
....
}%
在文档的开头,当它还未被定义时,赋予\creflastconjunction
其含义。\creflastconjunction@preamble
换句话说,\creflastconjunction
得到定义仅有的之后\begin{document}
。事实上,如果你尝试把这行
\newcommand{\creflastconjunction}{, and\nobreakspace}
在文档中,你会得到一个错误。在这种情况下,你应该写
\renewcommand{\creflastconjunction}{, and\nobreakspace}
答案2
简单回答:你可以使用
\newcommand{\creflastconjunction}{, and~}
来自手册:
\creflastconjunction
用于两个以上交叉引用的倒数第二个和最后一个之间 [第 12 页,至少在我拥有的 2012-03-07 版手册中是这样的]
重做你的例子:
\documentclass{article}
\usepackage\[standard\]{ntheorem}
\usepackage{cleveref}
\newcommand{\creflastconjunction}{, and~}
\begin{document}
\begin{proposition}\label{thm:roses}
Roses are red.
\end{proposition}
\begin{proposition}\label{thm:violets}
Violets are blue.
\end{proposition}
\begin{proposition}
42.
\end{proposition}
\begin{proposition} \label{thm:orchids}
Orchids are orchid.
\end{proposition}
\begin{theorem}
There exist flowers in at least three different colors.
\end{theorem}
\begin{proof}
Immediate from \cref{thm:roses,thm:violets,thm:orchids}.
\end{proof}
\end{document}
答案3
您可以使用\crefmultiformat
:
\documentclass{article}
\usepackage[standard]{ntheorem}
\usepackage{cleveref}
\crefmultiformat{proposition}{propositions~#2#1#3}%
{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\begin{document}
\begin{proposition}\label{thm:roses}
Roses are red.
\end{proposition}
\begin{proposition}\label{thm:violets}
Violets are blue.
\end{proposition}
\begin{proposition}
42.
\end{proposition}
\begin{proposition} \label{thm:orchids}
Orchids are orchid.
\end{proposition}
\begin{theorem}
There exist flowers in at least three different colors.
\end{theorem}
\begin{proof}
Immediate from \cref{thm:roses,thm:violets,thm:orchids}.
Immediate from \cref{thm:roses,thm:violets}.
\end{proof}
\end{document}