8

I am using the cleveref package to refer to theorems, equations, etc, in an article (LaTeX). I wish to have the format of reference as: Thm. (1) for single theorem (or equation, figure, etc) and Thms. (1,2) for a pair of (theorem) labels.

To achieve my required format with cleveref I do:

\usepackage{cleveref}
\crefformat{theorem}{Thm.~(#2{}#1{}#3)}
\crefname{theorem}{Thm.}{Thms.}
\newcommand{\crefpairconjunction}{ ,~}

However, I am not quite able to achieve the format required for the case where I have a pair of labels -- I require the counters in the reference to be enclosed by "(" and ")" parenthesis:

Thms. (1.1, 1.2)

Can anyone please help me modify the format for multiple labels case ? Since some had asked for a MWE, here is one:

\documentclass[12pt]{article}
\usepackage{amsmath}

\newtheorem{theorem}{Theorem}[section]

\usepackage{hyperref}
\hypersetup{colorlinks,linkcolor=blue}

\usepackage{cleveref}
\crefformat{theorem}{Thm.~(#2{}#1{}#3)}
\crefname{theorem}{Thm.}{Thms.}
\newcommand{\crefpairconjunction}{ ,~}

\renewcommand{\baselinestretch}{2}

\begin{document}

\section{\today}

Here is a sample theorem:
\begin{theorem} \label{thm-something}
Define something \dots
\end{theorem}

Here is another sample theorem:
\begin{theorem} \label{thm-some-other-thing}
Define some other thing \dots
\end{theorem}

I do not want references in this format: \cref{thm-something,thm-some-other-thing}

I want to enclose the counters by ``('' and ``)'' parenthesis. So it should be: ``Thms. (1.1, 1.2)''.
\end{document}

I have edited this question based on comments on its previous posting. (This question is a continuation of How to cross-reference several objects simultaneously )

2
  • can you give us a complete minimal working example (MWE) to play with?
    – cmhughes
    Oct 6, 2013 at 4:58
  • You say you want something like Eqs. (1,2,3) to be the result of cross-referencing the first three equations. What should be the result when cross-referencing equations 7, 8, 9, 10, 11, and 12: Should it be Eqs. (7--12) or Eqs. (7,8,9,10,11,12)? Please advise.
    – Mico
    Oct 6, 2013 at 11:42

1 Answer 1

8

The command \crefformat is meant for defining the formats of cross-references to single instances of an equation, a figure, a theorem, etc. To set up the formatting for a cross-reference to a range of items, you need to work with \crefrangeformat. The following setup may suit your needs:

\crefrangeformat{equation}{Eqs.~(#3#1#4--#5#2#6)}
\crefrangeformat{figure}{Figs.~(#3#1#4--#5#2#6)}
\crefrangeformat{theorem}{Thms.~(#3#1#4--#5#2#6)}

Be sure to use the command \crefrange{<first-label>}{<last-label>} when referring to ranges of labels.

By the way, you seem to have a lot of pairs of curly braces , {}, in your \crefformat instructions. These pairs probably aren't necessary.

4
  • This works, but still leaves the case with multiple labels that are not in range. For e.g. \cref{eq1, eq4}
    – kksagar
    Feb 4, 2022 at 12:50
  • @kksagar - Well, I'm sure relieved that you believe that my answer "works." My answer addressed the questions raised in the original query. I do not feel the slightest bit of embarrassment, let alone shame or inadequacy, for not having answered a question that was not asked to begin with. If you have a question about something that's not contained in the query above, please feel free to post a new query.
    – Mico
    Feb 4, 2022 at 12:54
  • My comment wasn't meant to embarrass or shame you in any way. I am sorry if you thought so
    – kksagar
    Feb 4, 2022 at 14:12
  • @kksagar - So maybe my choice of words was a bit [!] over the top. My point stands: I'm not bothered by somebody pointing out that I didn't address a question that wasn't asked to begin with.
    – Mico
    Feb 4, 2022 at 18:24

You must log in to answer this question.

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