2

The manual for cleveref states the following:

When cleveref typesets lists of multiple cross-references or page-references, the default behaviour is to automatically sort the list and compress sequences of consecutive cross-references or page numbers into a reference range. You can change this behaviour by supplying one of the following package options:

sort Sort lists of cross-references, but don’t compress consecutive references.

compress Compress sequences of consecutive references into a reference range, but don’t sort the list of cross-references.

nosort Neither sort lists of cross-references, nor compress consecutive references. sort&compress Sort lists of cross-references, and compress sequences of consecutive references into a reference range (this is the default).

Occasionally, you may want to prevent a particular sequence of consecutive cross-references from being compressed to a reference range, without disabling this feature globally.

However, it does not tell how to locally disable sorting the references. Is it possible to do such a thing?

MWE with output:

\documentclass{article}

\usepackage{cleveref}

\begin{document}
First equation:
\begin{equation}
\label{equation:first}
    a=2
\end{equation}
Second equation:
\begin{equation}
\label{equation:second}
    b=1
\end{equation}

As seen in \Cref{equation:second,equation:first}

\end{document}

enter image description here

The goal would be to have "As seen in Equations (2) and (1)" without deactivating the sorting at a more global scale.

2
  • 1
    you should always show a small but complete example that can be used for a test. Nov 30, 2022 at 15:41
  • @UlrikeFischer My bad, that's done! Nov 30, 2022 at 15:46

1 Answer 1

3

You can locally deactivate the sort feature:

\documentclass{article}
\usepackage{cleveref}

\makeatletter
\newcommand*{\Crefns}[1]{{\@cref@sortfalse\Cref{#1}}}
\makeatother

\begin{document}
First equation:
\begin{equation}
\label{equation:first}
    a=2
\end{equation}
Second equation:
\begin{equation}
\label{equation:second}
    b=1
\end{equation}

As seen in \Crefns{equation:second,equation:first}

\end{document}

Maybe you want also to deactivate the compress feature:

\documentclass{article}
\usepackage{cleveref}

\makeatletter
\newcommand*{\Crefns}[1]{{\@cref@sortfalse\@cref@compressfalse\Cref{#1}}}
\makeatother

\begin{document}
First equation:
\begin{equation}
\label{equation:first}
    a=2
\end{equation}
Second equation:
\begin{equation}
\label{equation:second}
    b=1
\end{equation}

As seen in \Crefns{equation:second,equation:first}

\end{document}

enter image description here

However, note, that this suggestions uses internals of cleveref. So it could fail in future, when the internals would change.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .