[pdftex] TOC-like hyperlinks inside/to index

Marc Lazareff Marc.Lazareff at onera.fr
Wed Nov 26 12:43:12 CET 2003


(This is an updated version a a previous post on nov. 20, probably 
ignored because of an un-updated email address)

Hello,

As the size of the index, for a document I am working on, has gone
beyond 20 pages, I felt some extra user help was needed to navigate this
mass (glob ?) of information.

The current solution I use is to implement a TOC-like structure for the
index, providing direct access to the index's alphabetical headings
(initial letter changes).

In fact, the navigation is slightly more elaborate, providing (from the
comments in the .sty file) :

%  a- a separate table of the index's alphabetical headings
%  b- the same links duplicated as special entries at the index's top
%  c- alphabetical headings inside the index
% Navigation is defined by the graphs : a-->c, c-->a and b-->c

Although I do find the result useful, the coding, see below, seems more
convoluted than necessary. This is because of the need to prevent TeX
from looping, using the current ideas

The attached "indextoc.tar.gz" archive includes an example result of the
current implementation, in the indextoc_test.pdf file, and the example
source (as LaTeX code, with the style file).

I wondered if someone had obtained a simpler solution to this kind of
problem, and would appreciate any comments.

Best regards,
Marc Lazareff

=============================


% macros for the index TOC hack
% \indextoc uses 2 levels of delayed link creations (avoiding TeX cycling)
% to provide a chain of hyperlinks between :
%  a- a separate table of the index's alphabetical headings
%  b- the same links duplicated as special entries at the index's top
%  c- alphabetical headings inside the index
% Navigation is defined by the graphs : a-->c, c-->a and b-->c
\newcommand{\indextoc}{%
   % \indextocfont is the font for index's alphabetical headings
   \def\indextocfont##1{\large\bfseries\sffamily\itshape##1}
   % \indextoclabel creates the hyperlink target for the separate 
headings table
   \def\indextoclabel##1{\hyperdef{index_toc}{##1}{}}
   % \indextocouter creates the alphabetical heading references at index top
 
\def\indextocouter##1{\index{~##1@{\hspace*{-1em}\protect\indextocbox##1}}\indextoclabel##1}
   % \indextoccommt creates the comment for an alphabetical heading's 
page link
   \def\indextoccommt{\par\footnotesize\mdseries\rmfamily(link is to 
index's alphabetical headings)}
   % \indextocbox creates a box around an alphabetical heading
 
\def\indextocbox##1{\makebox[5em]{\indextocfont\makebox[0em]{{\raisebox{.80ex}{\rule{0em}{1ex}}\raisebox{-.2ex}{\rule{0em}{1ex}}}}-- 
##1 --}}
   % \indextocinner creates a chain of links for a new alphabetical heading
   \def\indextocinner##1{%
\hyperref{\jobname.pdf}{index_toc}{##1}{\indextocbox##1}~~~\emph{p.}~\protect\pageref{index_toc_hd_##1}%
\index{##1@{\indextocfont{-- ##1 --} \protect\label{index_toc_hd_##1}%
\protect\indextoccommt}\protect\indextocouter{##1}}\\[1.2ex]}
\begin{center}
{\large Direct access to index sections~:}\\[3ex]
% explicit list of index's alphabetical headings
\indextocinner{A}\indextocinner{B}\indextocinner{C}\indextocinner{D}\indextocinner{E}\indextocinner{F} 
...
\end{center}
}

% the user interface of this package :
% a modified \printindex macro
\def\printindex{%
   \ifthenelse{\boolean{@pdf}}{\indextoc}{}
   {\let\@ti\theindex%
	 \def\theindex{\@ti}%
	 \label{index0}\InputIfFileExists{\jobname.ind}{}{}\label{index1}
   }
}

-- 
Marc Lazareff      Phone  : 01 46 73 42 73
  DSNA/ELSA         E-Mail : Marc.Lazareff at onera.fr
   ONERA 29,Ave de la Division Leclerc 92320 CHATILLON FRANCE




More information about the pdftex mailing list