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.

In a previous question I asked about customizing my table of contents. For now, I have decided to fill the table of contents simply like this for each article:

\addtocontents{toc}{\textit{\Author}\\}
\addtocontents{toc}{\hspace{1cm} \Title \dotfill \pageref{firstpage}–\pageref{lastpage}\\}

But I still have no clue how to indent the line(s) containing the title (if the title extends over more than one line, all lines should be indented by the same amount):

=== Author's Name ===

    === Title: 1st Line ===
    === Title: 2nd Line ===

Is there a simple solution?

share|improve this question
    
Instead of adding "(2)" to denote a follow-up question, I have made the question title more specific (and changed some tags). I hope you don't mind. –  lockstep Jan 4 '12 at 13:15

1 Answer 1

up vote 2 down vote accepted

Here is an example inspired of a few internal memoir macros, should work with any class:

\documentclass[a4paper]{memoir}
\newcommand\Title{This is a very long and complicated title that spans
several lines going on and on}
\newcommand\AuthorInToc[1]{\addtocontents{toc}{\protect\formatauthor{#1}}}
\newcommand\ArticleInToc[2]{\addtocontents{toc}{%
   \protect\formatarticle{#1}{#2}}}
\newcommand\formatauthor[1]{\noindent \textit{#1}\par}
\newcommand\formatarticle[2]{%
  \begingroup%
  \nopagebreak%
  \noindent%
  \setlength\leftskip{1cm}%
  \setlength\rightskip{4em}%
  \setlength\parfillskip{-4em}%
  \textit{Title:}~{#1}\dotfill\hbox to 4em{\hfil #2}\par%
  \endgroup%
}
\begin{document}

\tableofcontents*

\chapter{test}
\AuthorInToc{An Author}
\ArticleInToc{\Title}{1--5}
\end{document}

The idea is to remember that each entry in the TOC is actually a paragraph by it self, so treat it like that.

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.