TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to compress numbers of sections in a reference, but without repeating the chapter number, while maintaining full functionality of of hyperref and \ref.




I want the hyperref functionallity and automated references of 
but the look of 3.3--5. 
\ref{sec:chap3sec3}--\hyperref[sec:chap3sec5]{5} does half of what I want, 
but I don't know how to get the section number without chapter number.



How can I do this?

share|improve this question
Would using cleveref be an option? – Gonzalo Medina May 8 '12 at 14:22
@GonzaloMedina: \crefrange{eq1}{eq5} is typeset as Eqs.~(1.1) to~(1.5) according to the manual; \crefrangelabelformat allows to change the to~, but not the individual labels. Unless I missed something in the manual cleveref is no help. – Markus Schmassmann May 8 '12 at 14:36
I second Gonzalo's suggestion that you consider using the cleveref package and its \crefrange command. All sections in your document are numbered with the respective chapter number prefixed to the the section numbers, right? If that's the case, I think you're risking creating a lot of confusion among your readers if you omit the chapter number prefix from some of the section numbers used in a cross-reference. "Sections 3.3--3.5" is unambiguous, though not all that elegant. Do you want your readers to puzzle, however briefly, over whether "Sections 3.3--5" means "Section 3.3 to Chapter 5"? – Mico May 8 '12 at 15:16
@Mico: Given the context I use it in (outline of the MSc thesis, effectively an inline list) "3.3--5" is clear, so I would prefer it as asked. – Markus Schmassmann May 8 '12 at 15:32
@MarkusSchmassmann -- Both clarity and ambiguity are in the eye of the beholder, right? I must confess that I don't know how to implement the formatting requirement you've set out -- at least not within the framework of the cleveref package. – Mico May 8 '12 at 16:35
up vote 10 down vote accepted

LaTeX only stores the complete reference number. To get the section part of the number, the reference first needs to be extracted. Then the chapter part before the first dot can be stripped:



Usage: \ref{sec:chap3sec3}--\stripref{sec:chap3sec5}

share|improve this answer

Your Answer


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.