COMPGROUPS.NET | Browse | Post | Groups | Users | Stream | About | |

### multiline TOC entry

• Email
• Follow

Hello,

My documents sometimes have long titles, and these titles
don't fit into one line of TOC (table of content). I managed
to fix the problem by creating a macro:

[code]
% Generalized TOC entry
% #1 -- label
% #2 -- label width
% #3 -- ID
% #4 -- text
% #5 -- text font tuning
\newcommand{\tocX}[5]{%
% setup font
{#5%
% start a paragraph, reserve space for label and page number
\noindent\leftskip=#2\rightskip=3em% 3em > space + 9--99
% make a label
\hbox to 0pt{\kern-#2#1\hfil}%
% TOC entry text
#4\hfill
% page number
\hbox to 0pt{\hbox to 3em{\hfil\pageref*{#3}}\hss}%
% finish the box and the hyperlink
}}}\par}}
[/code]

TOC entries consist of three parts: label, text and page
number. If text is long and should be splitted on several lines,
then the text occupies only the text area.

Having "tocX", I define styles for actual TOC entries:

[code]
% Toc Entries
% #1 -- label
% #2 -- ID
% #3 -- text
\newcommand{\tocHI}[3]{\vspace{20pt}\tocX{Kapitel
#1}{2cm}{#2}{#3}{\V@SelectTOCFont\bfseries}%
\penalty10000\vspace{2pt}\hrule\penalty10000}
\newcommand{\tocHII}[3]{\vspace{12pt}\tocX{#1}{2.5cm}{#2}{#3}{\V@SelectTOCFont\bfseries}\penalty10000}
\newcommand{\tocHIII}[3]{\tocX{#1}{3cm}{#2}{#3}{\V@SelectTOCFont}}
\newcommand{\tocHIV}[3]{\tocX{#1}{3.5cm}{#2}{#3}{\V@SelectTOCFont}}
\newcommand{\tocHV}[3]{\tocX{#1}{4cm}{#2}{#3}{\V@SelectTOCFont}}
[/code]

and use in a document:

[code]
\toc
\tocHI{9}{id2295978}{Anhang}
\tocHII{9.1}{id2295983}{Weitere Dokumentation von ...}
\tocHII{9.2}{id2296568}{Dokumentation von Zulieferern}
\tocHII{9.3}{id2296683}{Normen}
[/code]

All works fine. I'm sharing the code in hope it will be useful.

My request: please comment how the code can be improved. For
example, I suppose that using "\vbox" is LaTeX is not very good,
but I have no idea for replacement.

Bye!

--
Oleg

 0
Reply usenet5437 (22) 8/31/2004 9:18:22 AM

See related articles to this posting

0 Replies
121 Views

Similar Articles

[PageSpeed] 16

Similar Artilces:

ToC questions -- formatting ToC entries
Hi All, I'm writing a reference document -- think 'encyclopedia-like' -- with a large number of entries in each section. I'd like the individual entries to show up in the ToC, but since they all (tend to) have very short names I don't want to have a huge number of pages that consist mostly of leaders between entry name and page number. The default ToC behavior would give me something like Chapter ...................................................... 1 Section 1 .................................................. 1 EntryA ...

Entries in TOC
I am contributing one part (Part 'D') of a publication. The formal requirement is that my chapters/sections/tables/figures are numbered with the prefix 'D-'. I have found the packages titlesec, titletoc, and caption for that purpose. - titlesec works fine - titletoc is troublesome. The code below produces unexpected results, whereever I put the 'D'. Both versions give an unexpected '0' and no D as a prefix %\titlecontents{chapter}[0.7cm] % {\vspace{0.3cm}} % {D~\thechapter\sffamily\bfseries\Large \contentslabel{1.7cm}} %...

How to list TOC entries?
Hi, When building our project with static libraries we regulary get TOC overflow warnings. I think that all global functions and variables go into the TOC. But correct me if I am wrong. We have also no problem to change the code to make the TOC smaller. But before we do that we want to know what in the TOC is. Is there a way to list all symbols contained in the TOC? I tried both dump and nm but they don't seem to give the answer I want. Joerg Joerg Richter wrote: > Hi, > > When building our project with static libraries we regulary get TOC > overflow warnings. I think t...

Removing entries from TOC
Hi all, I'm writing my PhD thesis with TeX and I have a table of contents in which I want to remove lines for "list of figures" and "list of tables". I also have "Table of contents" as entry in my TOC(!) and don't want that either... How can I remove these without manually editing the toc generated file? If it helps, I've copied my settings file below. Thank you Spiros Here are is my document (apart from actual text content) \documentclass[a4paper,12pt]{report} % document type \usepackage[pdftex]{graphicx} % driver \graphicspat...

toc entry is lost
Consider this \documentclass[a4paper]{article} \begin{document} \tableofcontents test \clearpage \addcontentsline{toc}{section}{hest} \begin{figure} \centering \rule{2cm}{2cm} \end{figure} \end{document} on my system (TL09) the toc ends up empty, why? -- /daleif (remove RTFSIGNATURE from email address) LaTeX FAQ: http://www.tex.ac.uk/faq LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish) Remember to post minimal examples, see URL below http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl http://www.minimalbeispiel.de/mini-en.html Lars Madsen <...

titlesec/Uppercase TOC entries
I am trying to follow the very inane thesis requirements my school has, but I am having trouble with the TOC chapter entries. The requirement for chapter headings and TOC entries are that they must be Uppercase. I would rather not type everything in as uppercase if I don't have to (I guess it wouldn't kill me, but I do plan to leave a latex template behind so the next poor sap doesn't have to go through all of this like I did). Because of other requirements (double spacing, only 12pt font allowed...), I am using the titlesec package. I have figured out how to fix the ch...

toc: centering entries for parts
How can I get table-of-content entries for parts be centered? That is, what I'd like to have is something along the lines of: Part 1 Mathematical Modeling 1. Chapter 1 2. Chapter 2 3. Chapter 3 Part 2 Numerical Methods 4. Chapter 4 etc. Thanks Andreas ...

setting TOC entries in a paragraph
Hi, I'm used to using tocloft to format the table of contents but scanning through the docs I don't see a solution to what I'm trying to do here. Rather than have every TOC entry on a new line I'd like to typeset the section entries in an indented paragraph under each chapter entry. Something like this. 1. The first chapter 1 The first section 1; Another section 3; A third sec 5; etc etc. 2. The second chapter 10 The first section 1; Another section 3; A third sec 5; etc etc. Does anyone ...

Special formatting of toc entries
Hi, I am using latex book class to write a laboratory manual for a class. I need to have my toc entries in such a way that I can get a short paragraph entry under the Chapter title as (I am not using sectional or subsectional entries at all to avoid extra clutter): Experiment 1 Title of Experiment 1 In this experiment we do bla bla bla bla bla bla bla bla bla Experiment 2 Title of Experiment 3 In this experiment we do more bla bla bla bla bla bla bla bla I ...