in which a question is posed concerning latex and tables of contents
October 2, 2010 9:56 AM Subscribe
Is there a way to generate an analytic table of contents using LaTeX?
Basically, under each chapter, section, subsection, yea even subsubsection, I would like (optionally) to include a bit of text roughly summarizing what goes on in that chapter, etc.
Here is an example of a page-by-page analytic TOC. That is a little too much.
Basically, under each chapter, section, subsection, yea even subsubsection, I would like (optionally) to include a bit of text roughly summarizing what goes on in that chapter, etc.
Here is an example of a page-by-page analytic TOC. That is a little too much.
Response by poster: Hm, I will keep that in mind, but I think I may be required to use the report class.
posted by kenko at 10:18 AM on October 2, 2010
posted by kenko at 10:18 AM on October 2, 2010
If you put text in square brackets after the \chapter, \section, \subsection et cetera then that gets displayed in the table of contents rather than the actual heading, e.g.
\section[This Appears in ToC]{This Appears at the Beginning of the Section}
perhaps you can use that to do what you are trying to do.
posted by Jabberwocky at 10:34 AM on October 2, 2010 [1 favorite]
\section[This Appears in ToC]{This Appears at the Beginning of the Section}
perhaps you can use that to do what you are trying to do.
posted by Jabberwocky at 10:34 AM on October 2, 2010 [1 favorite]
Best answer: Well, if you can't find any other package you can at least look at memoir.cls to see how it was implemented -- to do this in a general way you'll need to write stuff to the .toc file that is generated when there is a \tableofcontents command.
posted by advil at 10:43 AM on October 2, 2010
posted by advil at 10:43 AM on October 2, 2010
Do you know about the \addcontentsline and \contentsline macros? This is what the LaTeX sectioning commands use to write stuff to the table of contents, you can probably abuse them to achieve the desired output.
posted by Dr Dracator at 10:51 AM on October 2, 2010
posted by Dr Dracator at 10:51 AM on October 2, 2010
Response by poster: \section[This Appears in ToC]{This Appears at the Beginning of the Section}
Unfortunately what's in the square brackets also appears in the running head, which would be inappropriate. What I would like really would be something like this:
\section[Short title for TOC/running head][Description to go beneath TOC line]{Long title to appear in text}
E.g.: \section[Objections][Three objections to the theory proposed in the previous section are considered and the theory is slightly reformulated in response]{Three objections to the theory}
Using \contentsline directly is almost right except it still generates the line of dots to the right side of the page … I should probably do as advil advises and look intomemoir.cls.
posted by kenko at 11:11 AM on October 2, 2010
Unfortunately what's in the square brackets also appears in the running head, which would be inappropriate. What I would like really would be something like this:
\section[Short title for TOC/running head][Description to go beneath TOC line]{Long title to appear in text}
E.g.: \section[Objections][Three objections to the theory proposed in the previous section are considered and the theory is slightly reformulated in response]{Three objections to the theory}
Using \contentsline directly is almost right except it still generates the line of dots to the right side of the page … I should probably do as advil advises and look intomemoir.cls.
posted by kenko at 11:11 AM on October 2, 2010
Best answer: Check out the tocloft package as well, it contains some TOC manipulation/styling stuff you might find handy.
posted by Dr Dracator at 12:05 PM on October 2, 2010
posted by Dr Dracator at 12:05 PM on October 2, 2010
Response by poster: Turns out that memoir.cls uses tocloft.sty's methods.
posted by kenko at 12:37 PM on October 2, 2010
posted by kenko at 12:37 PM on October 2, 2010
Response by poster: However, I notice that each in its \chapterprecisetoc command includes "\righstkip \@tocrmarg\relax", but if I do that, LaTeX chokes. It seems to work fine if it's excluded, though.
posted by kenko at 12:53 PM on October 2, 2010
posted by kenko at 12:53 PM on October 2, 2010
Response by poster: This is what I ended up doing, if anyone's curious:
in preamble:
\ifdefined\chapter
\include{tocloft}
\fi
after document beginning:
\ifdefined\chapter
\newcommand{\chprecistoc}[1]{\addtocontents{toc}{%
\leftskip \cftchapindent\relax \advance\leftskip
\cftchapnumwidth\relax {\footnotesize \textit{#1}\protect\par}}}
\newcommand{\secprecistoc}[1]{\addtocontents{toc}{%
\leftskip \cftsecindent\relax \advance\leftskip
\cftsecnumwidth\relax {\footnotesize \textit{#1}\protect\par}}}
\newcommand{\subsecprecistoc}[1]{\addtocontents{toc}{%
\leftskip \cftsubsecindent\relax \advance\leftskip
\cftsubsecnumwidth\relax {\footnotesize \textit{#1}\protect\par}}}
\newcommand{\subsubsecprecistoc}[1]{\addtocontents{toc}{%
\leftskip \cftsubsubsecindent\relax \advance\leftskip
\cftsubsubsecnumwidth\relax {\footnotesize
\textit{#1}\protect\par}}}
\else
\newcommand{\chprecistoc}[1]{}
\newcommand{\secprecistoc}[1]{}
\newcommand{\subsecprecistoc}[1]{}
\newcommand{\subsubsecprecistoc}[1]{}
\fi
(The \ifdefined\chapter jazz is just there because I'm switching for various purposes between compiling the document as a report and as an article and I don't want the TOC (or various other things) if it's being treated as a report—obviously only the true branch is relevant.)
posted by kenko at 3:37 PM on October 2, 2010 [1 favorite]
in preamble:
\ifdefined\chapter
\include{tocloft}
\fi
after document beginning:
\ifdefined\chapter
\newcommand{\chprecistoc}[1]{\addtocontents{toc}{%
\leftskip \cftchapindent\relax \advance\leftskip
\cftchapnumwidth\relax {\footnotesize \textit{#1}\protect\par}}}
\newcommand{\secprecistoc}[1]{\addtocontents{toc}{%
\leftskip \cftsecindent\relax \advance\leftskip
\cftsecnumwidth\relax {\footnotesize \textit{#1}\protect\par}}}
\newcommand{\subsecprecistoc}[1]{\addtocontents{toc}{%
\leftskip \cftsubsecindent\relax \advance\leftskip
\cftsubsecnumwidth\relax {\footnotesize \textit{#1}\protect\par}}}
\newcommand{\subsubsecprecistoc}[1]{\addtocontents{toc}{%
\leftskip \cftsubsubsecindent\relax \advance\leftskip
\cftsubsubsecnumwidth\relax {\footnotesize
\textit{#1}\protect\par}}}
\else
\newcommand{\chprecistoc}[1]{}
\newcommand{\secprecistoc}[1]{}
\newcommand{\subsecprecistoc}[1]{}
\newcommand{\subsubsecprecistoc}[1]{}
\fi
(The \ifdefined\chapter jazz is just there because I'm switching for various purposes between compiling the document as a report and as an article and I don't want the TOC (or various other things) if it's being treated as a report—obviously only the true branch is relevant.)
posted by kenko at 3:37 PM on October 2, 2010 [1 favorite]
This thread is closed to new comments.
posted by advil at 10:15 AM on October 2, 2010