3

I want to change the conjunction used for a pair of equations. It keeps printing "and", I've tried a few different with \crefpairconjunction but I just can't get it to work. I didn't find anything which helps when googling around. Below is a minimal working example, the stuff in the preamble is what's currently in my report, is this affecting it?

Many thanks.

\documentclass{article}
\usepackage[sort&compress, % on multiple refs sort them and write as range
        capitalise, % Use Section not section etc.
        noabbrev, % Use Table not Tab. etc.
        nameinlink % Make the name (eg Section) part of the hyperlink
        ]{cleveref}
% just use (...) for equations
\crefformat{equation}{#2(#1)#3}
\crefrangeformat{equation}{#3(#1)#4--#5(#2)#6}
\crefmultiformat{equation}{(#2#1#3)}{ and~(#2#1#3)}{, (#2#1#3)}{ and~(#2#1#3)}

% Except for start of sentences where we need to say "Equations"
\Crefformat{equation}{Equation~#2(#1)#3}
\Crefrangeformat{equation}{Equations~#3(#1)#4--#5(#2)#6}
\Crefmultiformat{equation}{Equations~(#2#1#3)}{ and~(#2#1#3)}{, (#2#1#3)}{ and~(#2#1#3)}

\begin{document}
\begin{equation}
e_1
\label{eq1}
\end{equation}
\begin{equation}
e_2
\label{eq2}
\end{equation}

This has an `and' \cref{eq1,eq2}

But I want this: \cref{eq1}--\cref{eq2}

\end{document}
  • Not directly related to your question, but still of relevance: Since you've set the option nameinlink, you should probably change \Crefrangeformat{equation}{Equations~#3(#1)#4--#5(#2)#6} to \Crefrangeformat{equation}{#3Equations~(#1)#4--#5(#2)#6}, i.e., include "Equations~" inside the scope of the hypertarget. – Mico Oct 31 '15 at 9:22
3

You need to include the instruction

\newcommand\crefpairconjunction{--}

in the preamble.

A full MWE:

enter image description here

\documentclass{article}
\usepackage[colorlinks]{hyperref}% just for this example
\usepackage[capitalise,noabbrev,nameinlink]{cleveref}
\newcommand\crefpairconjunction{--}
\crefname{equation}{}{} % no "equation[s]" label mid-sentence
\Crefname{equation}{Equation}{Equations}

\begin{document}
\begin{equation} e_1 \label{eq1} \end{equation}
\begin{equation} e_2 \label{eq2} \end{equation}

This expression no longer has an `and': \cref{eq1,eq2}.

And this one doesn't either: \Cref{eq1,eq2} \dots
\end{document}

For more information on the \crefpairconjunction macro, I recommend p. 13 of the user guide of the cleveref package.

  • Strangely enough, taking out the the line "\Crefname{equation}{Equation}{Equations}" puts the "and"s back in. I haven't read through page 13 yet, doing that now. Many thanks. – Ren Oct 31 '15 at 9:43
  • Works fine without the "\Crefname{equation}" line for me, at least with the latest pre-release available from my web site: dr-qubit.org/latex.html Perhaps an update fixed whatever bug was causing that. – Toby Cubitt Jun 12 '17 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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