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 class jurabook and I want to change the behavior of the table of contents. jurabook offers the possibility of having runners that number the paragraphs. These runners offer a more specific reference than pages.

I would like the table of contents to show the references to the runners instead of the pages or even better in addition to the reference to the pages. Is it possible to change the behavior of the table of contents accordingly?

Here is a minimal example of a document using jurabook and runners.

\documentclass[compact,a5paper,12pt]{jurabook}
\usepackage[a5paper, left=1.5cm, right=1.5cm, top=2cm, bottom=1.5cm]{geometry}

\newcommand{\lorem}{\rn{Lorem} ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

}

\begin{document}

\tableofcontents

\chapter{Chapter}
\section{Test}
\lorem
\lorem
\section{Test 2}
\lorem
\lorem
\lorem
\section{Test 3}
\lorem
\lorem
\section{Test 4}
\lorem
\lorem
\end{document}

Edit:

Thank you very much for your answer. It works within the minimal example. But I have problems applying it to a broader scale.

If I include the hyperref package, the solution does not work. I am getting errors on typesetting.

And if I want some indication of which number is which, the text runs out of the page. For example using the code:

\def\addcontentsline#1#2#3{%
  \addtocontents{#1}{%
     \protect\contentsline{#2}{#3}{page \thepage\ (runner \the\numexpr\value{runner}+1\relax)}}}%
share|improve this question
    
According to jurabook.cls, that feature has been considered, but has not yet been implemented by the author of the class file. Search for "rnintoc" in the file: Sollen auch die Randnummern in das Inhaltsverzeichnis mit aufgenommen werden? (funktioniert noch nicht!) In English: Should the runners also be included in the table of contents? (doesn't work yet!) You will have to implement the feature yourself or wait for a proper answer to your question. –  Jubobs Apr 4 '13 at 10:30

1 Answer 1

up vote 3 down vote accepted

Here is one way of doing it.

Caution: one weakness of the solution is that, even if a section contains no \rn, it will still be associated (in the toc) to a runner value corresponding to that of the preceding \rn plus 1.

enter image description here

\documentclass[compact,a5paper,12pt]{jurabook}
\usepackage[a5paper, left=1.5cm, right=1.5cm, top=2cm, bottom=1.5cm]{geometry}
\usepackage{titletoc}

\newcounter{runnerplusone}

\renewcommand\addcontentsline[3]{%
    \setcounter{runnerplusone}{\value{runner}}%
    \addtocounter{runnerplusone}{1}%
    \addtocontents{#1}{%
    \protect\contentsline{#2}{#3}{\thepage\ (\therunnerplusone)}}}


\newcommand{\lorem}{\rn{Lorem} ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
}

\begin{document}
\tableofcontents
\chapter{Chapter}
\section{Test}
\lorem
\lorem 
\section{Test 2}
\lorem
\lorem
\lorem
\section{Test 3}
\lorem
\lorem
\section{Test 4}
\lorem
\lorem
\end{document}

An alternative (proposed by David Carlisle) using etex arithmetic to avoid allocating a new counter is

\def\addcontentsline#1#2#3{%
  \addtocontents{#1}{%
     \protect\contentsline{#2}{#3}{\thepage\ (\the\numexpr\value{runner}+1\relax)}}}

EDIT: the solutions above break if hyperref is loaded. To circumvent the problem, egreg proposed the following:

\documentclass[compact,a5paper,12pt]{jurabook}
\usepackage[a5paper, left=1.5cm, right=1.5cm, top=2cm, bottom=1.5cm]{geometry}
\usepackage{titletoc}
\usepackage{xpatch}
\usepackage{hyperref}

\xpatchcmd\addcontentsline{\thepage}{\thepage\ (\the\numexpr\value{runner}+1\relax)}{}{}

\newcommand{\lorem}{\rn{Lorem} ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.
}

\begin{document}
\tableofcontents
\chapter{Chapter}
\section{Test}
\lorem
\lorem 
\section{Test 2}
\lorem
\lorem
\lorem
\section{Test 3}
\lorem
\lorem
\section{Test 4}
\lorem
\lorem
\end{document}
share|improve this answer
1  
you just beat me:-) But I posted mine anyway as I think you want to evaluate runner earlier, the write is a delayed write so that you get the correct page number.. ooh no protected@write does that I'll delete... –  David Carlisle Apr 4 '13 at 11:15
    
@DavidCarlisle That was a close race :) but I think that your solution was more elegant and that you should undelete it. –  Jubobs Apr 4 '13 at 11:18
    
well it had a pointless expansion step, I deleted that bit and added it to the end of your answer, no need for two answers here really. –  David Carlisle Apr 4 '13 at 11:27
    
Thank you very much for your answer. It works within the minimal example. But I have problems applying it to a broader scale. Using the hyperref package, I get an error on typesetting. And if I want some indication of which number is which, the text runs out of the page. For example using the following line \protect\contentsline{#2}{#3}{page \thepage\ (runner \the\numexpr\value{runner}+1\relax)}}} –  Michael Apr 5 '13 at 8:50
    
To give more visibility to those issues you're having, you should uncheck my answer for the time being, and update your question (write about the new issues after "EDIT:" at the end of your question). –  Jubobs Apr 5 '13 at 10:09

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.