0

The Latex toc is structured by default on several lines: each line of text represents the single chapter, or section, or subsection, while the paragraph indents distinguish the various levels of the parts of the document.

However, for my next paper I need to write a toc in a single paragraph (with the omission of the page numbers of the individual parts mentioned). If I write an [article], I would need in this toc the section to distinguish itself from the subsections because it is written in bold type. I enclose the photo of the result that I would like to obtain.

enter image description here

Naturally, the entries of this index in a single paragraph should be linkable, in the same way as those of the toc by default, with the hyperref package.

Moreover, such an index model would also be perfect for [books], within each chapter, compared to individual minitocs.

Obviously, the decorations (like the two lines in the image) I can easily make them myself. What I need is the code to set the toc in a single paragraph, with section in bold and subsection in normal text.

2
  • Something like this? \usepackage{titletoc} \titlecontents*{section}[0cm]{}{\bfseries\thecontentslabel\ }{}{}[A][][] \titlecontents*{subsection}[0cm]{}{\thecontentslabel\ \itshape}{}{}[:\ ][;\ ][.\ ]
    – Ivan
    Commented Feb 27, 2021 at 17:17
  • Yes, there is no possibility here to use a tilde between the part number and its label and I still have to understand how to make it work only, in the [book] class, for the minitoc. But it is a good starting point. Thank you. Commented Mar 2, 2021 at 14:03

1 Answer 1

0

The code showed by Ivan is ok, so, just loaded titletoc package, the code with the tilde I asked for is:

\titlecontents*{section}[0cm]{}{\bfseries\thecontentslabel~}{}{}[][][]
\titlecontents*{subsection}[0cm]{}{\thecontentslabel~}{}{}[:\ ][;\ ][.\ ]

If someone preferes to input the name of the content into the toc, simple add the command between the braces after the first squadre brackets.

\titlecontents*{section}[0cm]{\textbf{\textsc{\contentsname}}.~}{\bfseries\thecontentslabel~}{}{}[][][]
\titlecontents*{subsection}[0cm]{}{\thecontentslabel~}{}{}[:\ ][;\ ][.\ ]

It is important to add following command, in order to justify the content's paragraph.

\contentsmargin{0cm}

Then, about the minitoc for book class: I have found a solution different from the minitoc package. Maybe, it's better the shorttoc package, with following code:

\usepackage{shorttoc}
\newcommand*\generalcontentsname{General content}
\usepackage{titletoc}
\setcounter{tocdepth}{1}
\newcommand\partialtocname{Headlines}
\newcommand{\chaptertoc}{\startcontents\printcontents{l}{1}{\setcounter{tocdepth}{2}}}
\titlecontents*{lsection}[0cm]{\small\textsc{\textbf{\partialtocname.~}}}{\small\bfseries\thecontentslabel~}{}{}[]
\titlecontents*{lsubsection}[0cm]{}{\small\thecontentslabel~}{}{}[:\ ][;\ ][.\ ]
\newcommand{\printminitoc}{\begin{addmargin}[0.5cm]{-0.5cm}\chaptertoc\end{addmargin}} % This line in order to justify the toc.

Then, in the document we have first of all to add the command \printminitoc after the command \chapter{}. Then, we have to add the command \shorttoc{\generalcontentsname}{1}, in order to print our Headlines. Last, we have to add the common command \tableofcontents, at the point where we want a more precise and lowed index.

1
  • Welcome to TeX.SE!
    – Mensch
    Commented Jun 30, 2021 at 16:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .