Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Simple question: Is there a simple way to get cleveref to use the Oxford comma?

\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}

Output

Should say “propositions 1, 2, and 4.”

share|improve this question
1  
Just wanted to make a note that the Oxford Comma is more generally known as a Serial Comma. Mostly noted for search engine indexing. –  Patrick Feb 20 at 16:12
    
Well, it looks like Google knows they're synonyms, but thanks :-) –  Luke Maurer Feb 20 at 20:06
add comment

3 Answers 3

up vote 24 down vote accepted

If you define this new command

\newcommand{\creflastconjunction}{, and\nobreakspace}

you will get Oxford comma everywhere you use multiple references like those.

MWE:

\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} 

Output:

enter image description here


ADDENDUM

If you were wondering why you have to use \newcommand instead of renewcommand, this is why.

cleveref defines, at the beginning of the document, a lot of commands depending on the language. If you don't specify any language, english is loaded. This is the relevant part of cleveref.sty:

\DeclareOption{english}{%
  \AtBeginDocument{%
    ....
    \def\creflastconjunction@preamble{ and\nobreakspace}%
    ....

Also, you can find the following lines

\AtBeginDocument{%
  ....
  \@ifundefined{creflastconjunction}{%
    \let\creflastconjunction\creflastconjunction@preamble%
  }{%
  ....
  }%

which, at the beginning of the document, assign to \creflastconjunction the meaning of \creflastconjunction@preamble when it has not been defined yet.

In other words, \creflastconjunction gets defined only after \begin{document}. In fact, if you try to put the line

\newcommand{\creflastconjunction}{, and\nobreakspace}

inside the document, you will get an error. In this case, you would have written

\renewcommand{\creflastconjunction}{, and\nobreakspace}
share|improve this answer
    
Even better, thanks! –  Luke Maurer Feb 19 at 20:24
1  
+1 For generality. –  Gonzalo Medina Feb 19 at 20:30
add comment

You can use \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}

enter image description here

share|improve this answer
    
Aha! It's a little piecemeal (will need to repeat for different theorem sets), but it should work. Thanks. –  Luke Maurer Feb 19 at 20:14
    
@LukeMaurer see karlkoeller's answer for a solution affecting all reference types. –  Gonzalo Medina Feb 19 at 20:23
    
Out of curiosity, why the #2#1#3 instead of #1#2#3? –  Sean Allred Feb 20 at 4:14
add comment

Simple answer: You can use

\newcommand{\creflastconjunction}{, and~}

From the manual:

\creflastconjunction is used between the penultimate and final cross-reference in a list of more than two [pg. 12, at least for the 2012-03-07 version of the manual I have]


Redoing your example:

\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}

The compiled example, saying "Immediate from propositions 1, 2, and 4."

share|improve this answer
    
This is already in my answer... –  karlkoeller Feb 19 at 20:22
    
Shouldn't that be \renewcommand? –  Luke Maurer Feb 19 at 20:23
    
@LukeMaurer: You'd think so, but surprisingly not. –  Antal S-Z Feb 19 at 20:23
    
So cleveref is actually checking for the existence of that macro? Weird. *shrug* –  Luke Maurer Feb 19 at 20:24
    
@karlkoeller: So it is! I guess great minds think alike; I must have started writing my answer while you were finishing writing yours. –  Antal S-Z Feb 19 at 20:25
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.