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'm quite often using references to corresponding sections or text blocks in my thesis.

In consequence, I've already defined a lot of \label{} commands, which I tried to classify with a naming convention like int:txt:WhatIsItAbout for making clear, that it is in the Chapter introduction, refers to a text block and it's about ...

However, all the page references only contain the page where the label is typeset. If I'm referring to a chapter or section which spans more than one page, I'd like to have a page number like S. 23f or S. 23ff

By referencing text blocks it seems even more complicated (as the end of the range is not defined by the occurrence of the next object on the same level): I add a label somewhere, but to define a text range, I would have to define a second label at the end of the text block which would make things even more confusing.

I know about the variorefpackage which can produce such "intelligent" references, but for a page range it also needs 2 labels.
(as described here: Creating a "\label" that, if necessary, spans over several pages)

  • Is there a way to avoid that by e. g. defining an environment which
    • can be referenced and which automatically outputs the start and end page?
    • or which creates 2 labels at its beginning and at its end which are e. g. called LabelnameS and LabelnameE (for start and end) and
      • can be read by either the \vref command with explicitly entering the 2 label names
      • or by a specially defined ref command \rangeref{Labelname} which expands it automatically and creates the page range, if start and end are on different pages.

Remark: However, if really an environment would be used for that, it could cause problems if 2 such environments "intersect" (start of 2nd environment before end of first, but end of second environment after end end of first).

  • How do you handle that?
    • Do you avoid referencing to page ranges or do you always create 2 labels?
    • How do you name your labels to make them short and clear?
share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

Since your ranges may intersect, defining an environment is out of the question. It's necessary to mark the start and the end of the range and two labels are to be created; however, LaTeX can do it for you:

\newcommand{\rangelabelstart}[1]{\label{#1START}}
\newcommand{\rangelabelend}[1]{\label{#1END}}

\newcommand{\rangeref}[1]{\ref{#1START}--\ref{#1END}}
...
\begin{document}
...
\rangelabelstart{xyz}
Text
\rangelabelend{xyz}
...
\rangeref{xyz}

You provide only one label, leaving to LaTeX the task of using two of them. Of course you'll have to better define the action of \rangeref. The zref package should be considered for advanced label-ref managing.

share|improve this answer
    
thanks, egreg - I'll need some more days to test and see how it works best and then give you a feedback! –  Martin Apr 18 '11 at 10:48
add comment

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.