4

I want to format the table of contents of a reader in a non-standard manner, see example:

enter image description here

In particular, the sections are listed 'inline', without page numbers, separated by bullets and indented w.r.t. the chapter listing. The unnumbered 'chapters' (bibliography, index, etc.) at the end of the document are aligned with the chapter numbers, not indented.

Unfortunately I haven't been able to find a transparent explanation of how to achieve this. A bit of searching got me to this question on this site, which has an answer with a table of contents that looks somewhat similar to what I'm looking for, see the image below.

The problem is that the accompanying code is a complete mystery to me, I am unable to find any useful correlation between the code and the output. I hope someone here can either explain to me what the code does, or show me another way to get the look I want. Needless to say I'm a novice at TeX.

enter image description here

Thanks in advance

  • 2
    The manual to the etoc package has an example of something like this, if I remember correctly – user31729 Sep 16 '16 at 19:19
  • 3
    Also look at the titletoc/titlesec documentaion. – Werner Sep 16 '16 at 19:35
  • etoc is very powerful. If you are using titlesec, titletoc will cooperate with it. The best approach depends on minimal information about your document which we don't have. A minimal example would be helpful in this respect. – cfr Sep 16 '16 at 23:43
6

Here is a solution using etoc package

\documentclass{book}
\usepackage{mwe}

\usepackage{etoc}
\setcounter{tocdepth}{1}

\begin{document}
\begingroup
\parindent=0pt
\etocsetstyle{chapter}
{}
{\leavevmode\leftskip0em\relax}
{\etocifnumbered{\makebox[1.5em][l]{\etocnumber.}}{}%
\etocname\nobreak\hfill\nobreak
\rlap{\makebox[1.5em]{\etocpage}}\par}
{}
\etocsetstyle{section}
{\begingroup\leftskip1.5em\relax}
{\textbullet\hspace\itemsep%
\nolinebreak}
{\etocname\space}
{\par\endgroup}
\tableofcontents
\endgroup

\blinddocument
\blinddocument
\cleardoublepage
\addcontentsline{toc}{chapter}{\bibname}
bye
\end{document}

enter image description here


Update (edited)

\documentclass{book}
\usepackage{mwe}

\usepackage{etoc}
\setcounter{tocdepth}{1}

\begin{document}
\begingroup
\parindent=0pt
\etocsetstyle{chapter}
{}
{\leavevmode\leftskip0em\relax}
{\etocifnumbered{\makebox[1.5em][l]{\etocnumber.}}{}%
\etocname\nobreak\hfill\nobreak
\rlap{\makebox[1.5em]{\etocpage}}\par}
{}
\etocsetstyle{section}
{\begingroup\leftskip1.5em\relax}
{\etociffirst{}{\textbullet\hspace\itemsep%
\nolinebreak}}
{\etocname\space}
{\par\endgroup}
\tableofcontents
\endgroup

\blinddocument
\blinddocument
\cleardoublepage
\addcontentsline{toc}{chapter}{\bibname}
bye
\end{document}
|improve this answer|||||
  • alternatively you can use \etociffirst{<do nothing>}{<put the bullet>}. – user4686 Oct 14 '16 at 17:51
  • @jfbu of course this is better. – touhami Oct 14 '16 at 18:19
  • @Servaes answer edited following jfbu's comment. – touhami Oct 14 '16 at 18:23
  • @Servaes Ok, sorry, i edited my answer again :-) – touhami Oct 15 '16 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.