multiline TOC entry

  • Permalink
  • submit to reddit
  • 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 hyperlink and a link rectangle
\hyperlink{#3}{\hbox to \hsize{\vbox{%
% 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

comp.text.tex 36689 articles. 70 followers. Post

0 Replies
195 Views

Similar Articles

[PageSpeed] 39


Reply:

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...

amsart toc double entry
hi, i am using the amsart documentclass. at the end of the document i include a bibtex file with: \bibliography{biblio} doing this results in two entries in the table of contents (\tableofcontents) for the References section. anybody an idea how i can get rid of one of these two entries? they are both pointing to the starting page of the reference section ... thanks m Makus wrote: > hi, > i am using the amsart documentclass. > at the end of the document i include a bibtex file with: > \bibliography{biblio} > > doing this results in two entries in the table of contents >...

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 ...

suppressing numbering of entries in toc
I am putting together some pdf-files usinfg the pdfpages-package like this: \documentclass[a4paper,11pt,twoside,oldtoc]{article} \usepackage[final]{pdfpages} \makeatletter \renewcommand*\l@section {\@dottedtocline{1}{0em}{2.3em}} \makeatother \begin{document} \tableofcontents \cleardoublepage \includepdf[pagecommand={},addtotoc={1,section,1,title of first document,label1}, pages={1-9}]document1.pdf} \cleardoublepage \includepdf[pagecommand={},addtotoc={1,section,1,title of 2nd document,label2}, pages={1-7}]{document2.pdf} \cleardoublepage .. .. .. \end{document} This all works fine...

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 ...

alternative for unnumbered entries in toc
Hi, I'm using the standard \getcontentsline in conjunction with the starred version of sectioning type to produce unnumbered entries in ToC. Unfortunately, i have to type the same title twice as a result of this. E.g. \subsubsection*{some really annoyingly long heading} \addcontentsline{toc}{subsubsection}{some really annoyingly long heading} Can anyone recommend some more user friendly alternative to produce the same result? Cheers :) On Nov 11, 1:41=A0am, pretentious_indifference <smart.spo...@gmail.com> wrote: > Hi, > > I'm using the standard \getcontentslin...

Raggedright entries in toc with memoir
Hi all, I'm using memoir with pdfLaTeX to typeset a book. The book has some chapters with long titles, so that they take several lines in the table of contents. However, I can't get them raggedright and sometimes the lines have ugly interword space. Here is a test case: ========================= 8< ============================== \documentclass{memoir} \renewcommand{\cftchapterbreak}{\hyphenpenalty10000\sloppy} \renewcommand{\cftchapterfont}{\Large} \begin{document} \tableofcontents* \chapter{This is a chapter with a long title, which should be~typeset~raggedright in the table ...

Remove entries form TOC
Hello! Is it possiblie to remove some chapters from the table of contents? Something like \removecontentsline{toc}{Chapter}{Errata} Best Regards AD Am 16 Oct 2008 08:52:44 GMT schrieb Alexandros Droseltis: > Hello! > > Is it possiblie to remove some chapters from the table of contents? > Something like \removecontentsline{toc}{Chapter}{Errata} You can change locally tocdepth to e.g. -1 with the tocvsec2 package. -- Ulrike Fischer Ulrike Fischer <news2@nililand.de> schrieb: > Am 16 Oct 2008 08:52:44 GMT schrieb Alexandros Droseltis: > >> Hello! >> ...

Typesetting TOC with memoir (how to flushleft entries)
I've trying to understand the TOC typesetting stuff in the Memoir class. I've almost succeeded to get what I want except for one thing. I would like not my entries justified. You'll find a page example here: http://www.guyverville.com/documents/604.jpg The problem is in the section definition (which serves here to make the level before part and chapter (this book is a set of three novels, and one of them have special division. Since I don't use the section level in the book, i coded my fake section adding contents to TOC using the section level.) I have not seen a way t...

memoir: format of paragraph entries in TOC
This post is concerned with the memoir class. I would like to modify the font used to typeset the paragraph-level entries in the table of contents to be smaller, so in accordance with the instructions on pages 96 and 97 of the memoir documentation, I added the following line to my document preamble: \renewcommand{\cftparagraphfont}{\small} I get an error message telling me that \cftparagraphfont is not defined. After looking at the source code in memoir.cls, it appears that the paragraph entries are set using the font specified by \cftsubsubsectionfont. I am going to try redefining the ...

Help w/ TOC and Unnumbered Entries
I wish to add unnumbered entries in the TOC that refer to particular pages in the document without adding an additional section, subsection, etc. in the document. For example: 1. CH 1 1.1 Topic 1 Selection A Selection B 1.2 Topic 2 These commands accomplish the task: \subsection*{Selection A} \addcontentsline{toc}{subsection}{Selection A} but insert "Selection A" in the text as well as an extra line. Leaving the argument of \subsection* blank, I get rid of "Selection A" in the text, but I still have an extra line. What I would like is some way to mark and name a particu...

Tk:TableMatrix
Hi, after seeing that it is possible to have in the title row text entries separated by newline \n within a single cell, I wondered why this seems not to be possible for an ordinary cell. Does anyone have an idea about out? Please check out the code example: use Tk; use Tk::TableMatrix; my $mw = MainWindow->new; my $titleHash = { "0,0" => "abc", "0,1" => "123\ndef", }; my $table; $table = $mw->Scrolled('EMatrix', -titlerows => 1, -roworigin => 0, -colorigin =&...

[Memoir] Extra space in TOC entry for \part
I noticed an extra space in the table of contents for \part entries after updating to the latest memoir.cls (2008/05/26 v1.61803 - mempatch.sty v5.1). The space is placed before foo in the following example: \documentclass[11pt,danish,a4paper,twoside,openright,onecolumn,final]{memoir} \usepackage[danish]{babel} % SOLUTION %\makeatletter %\renewcommand{\partnumberline}[1]{% % \hb@xt@\@tempdima{% % \cftpartname\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb} %\makeatother \begin{document} \tableofcontents \cleardoublepage \part{foo\\bar} \chapter{foo\\bar} \end{document} As far as I can tel...

python logging, handling multiline log entries
Hi python fellows, I'm looking to do the following : import logging l = logging.getLogger('aHeader') l.handlers = [] l.addHandler(logging.StreamHandler()) l.handlers[-1].setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(message)s")) l.error('1st line\n2nd line') output: 2010-11-04 12:22:05,593 - aHeader - 1st line 2nd line I'd like to get something like: 2010-11-04 12:22:05,593 - aHeader - 1st line 2nd line I don't want to get the header on every line, otherwise I would just nee...

memoir: dotted Part and Chapter ToC entry?
Dear All, I am a bit confused as my publisher wants me to typeset /all/ lines of the table of contents of my upcoming book with dotted leaders, including the Part and Chapter entries (and I have 36 chapters). However, the memoir manual (the version I use says: last changed 2011/03/06) has on the last text line of page 155: "Dotted leaders are not available for Part and Chapter ToC entries." Is there a possibility to bypass this restriction? Also, the page numbers of part and chapter entries are printed boldface, my publisher prefers regular weight. Is there a chan...

hyperref: getting non-toc entries in bookmarks
I use the hyperref package with options (among others) bookmarks, bookmarksnumbered. I would like to get non-toc entries in the bookmarks list of a pdflatex'ed file (e.g., title page, copyright page, dedications page). If this is possible, can I create a hierarchy (e.g., `chapter' Pre, with `sections' title, copyright, dedication)? Thanks in advance, Erik ...

chapter title, ToC entry, and page header
Hi, I have a rather long chapter title, which I want to appear in a shorter version in the header of (even) pages, but *not* in the toc; there, the long title should appear. Hence, the usual way with \chapter[Abbrev. title]{Very long title} doesn't work. I have tried to set it explicitly with \fancyhead[CE]{Abbrev. title}, but then, of course, it will appear in the subsequent chapters as well instead of the current chapter title. The \addtocontents way is maybe possible, but certainly too clumsy in this case. There must be a way to do this, and it's probably pretty trivial, but I can&#...

Small capitals in Section, uppercase in the TOC entry
Hi, I am preparing a manuscript for a Journal whose style has: * the Section titles in small capital letters * the corresponding TOC entry in ordinary letters Now, my Section title has a word with initials, LDH. If I write it in the Section entry as "ldh", I get the correct LDH in lowercase capitals in the Section, but I get plain lowercase in the TOC. I can get the correct uppercase LDH in the TOC if I write it as "LDH" in the Section title, but then I get an uppercase word in the middle of small capitals in the Section title. Is there a way to fix this? Thanks, Dim...