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 have one problem in the latex \tableofcontents.

Look at the image I circled.

For Dictionary from A-Z               1-250

How to do that in latex in \tableofcontents?

Is it possible in LaTeX?

enter image description here

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Well, the command \addtocontents{toc}{STUFF} adds anything you want to the table of contents. You need to format your entry yourself, however.

If you look into TOC of a LaTeX file, you see that its entries have the following structure \contentsline {SECTION}{\numberline {NUMBER}TITLE}{PAGE}{HYPERLINK NAME} (the last argument is there only if you use hyperref). So you need to:

  1. Put \label{first_page} on the first page.

  2. Put \label{last_page} on the last page

  3. Put on the first page \addtocontents{toc}{\contentsline {section}{\numberline{} Words}{\pageref{first_page}--\pageref{last_page}}{}}

You many need to change section to chapter here depending on the style you want.

Good luck!

share|improve this answer

Your information are really spare. The modification based also on the packages which creates the index. For example you can use makeidx, scrindex or splitidx ...

In my example I uses the class scrbook in combination with scrindex:

\documentclass[ngerman,idxtotoc]{scrbook} 
\usepackage{babel}
\usepackage{scrindex}
\usepackage{etoolbox}
\usepackage[user,abspage]{zref}
\usepackage{hyperref}
\makeatletter
\renewcommand*{\idx@heading}{%
  \if@openright\cleardoublepage\else\clearpage\fi%
  \twocolumn[\idx@@heading{\indexname}]%
  \@mkboth{\indexname}{\indexname}%
}
\renewcommand*\idx@@heading[1]{%
   \phantomsection
   \chapter*{\hypertarget{indexlink}{#1}}\zlabel{startindex}
   \addtocontents{toc}{\protect\addvspace{\@chapterlistsgap}}
   \addtocontents{toc}{%
            {\usekomafont{chapterentry}%
             \protect\hyperlink{indexlink}{\indexname}%
             \protect\hfill%
             \zpageref{startindex} -- \zpageref{endindex}%
            }}
}
\AtEndEnvironment{theindex}{\zlabel{endindex}}
\makeindex
\begin{document} 
\tableofcontents
\chapter{foo}
Text\index{Text}
\printindex
Test
\end{document}
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.