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.

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 )

share|improve this question
    
can you give us a complete minimal working example (MWE) to play with? –  cmhughes Oct 6 '13 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 '13 at 11:42

1 Answer 1

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.

share|improve this answer

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.