2

I have some sections without a number, but which I would like to have with a dotted line. However they automatically get the indentation of a section as that is globally defined with \tableofcontents. Is it possible to remove the indentation before the "1 Context" but uphold the indentation afterwards?

\documentclass[11pt]{report} ... \begin{document} \section*{Inhoudsopgave} \makeatletter \@starttoc{toc} \makeatother \section*{Inleiding} \addcontentsline{toc}{section}{\protect\numberline{}Inleiding}% ... text ... \chapter{Context} ... \end{document} 

toc

4
  • \usepackage{tocloft} will give a clue. Whether this will work with one of the \cftXindent commands depends on the class, however. Please post a working example, not just a screen shot of the desired outcome Commented Feb 24, 2017 at 13:38
  • I haven't tried tocloft yet as I pressumed this was possible without extra packages. I have added my example which generates this. Commented Feb 24, 2017 at 13:49
  • Hm, why \@starttoc{toc} instead of \tableofcontents? Commented Feb 24, 2017 at 13:51
  • The title was too big, but I fixed it now and reapplied "\tableofcontents" Commented Feb 24, 2017 at 14:05

1 Answer 1

6

The length \cftsecindent with tocloft package controls the indentation of sections. It should be written to the ToC itself and wrapping a group around this, so \addtocontents{toc}{\begingroup....}...\addtocontent{toc}{\endgroup} in order to limits its range only to the first unnumbered sections.

The \protect commands are necessary since \setlength is fragile and will break during the writing process.

Side remark: The tocloft package defines a lot of \cftX.... commands where X is either chap, sec, subsec etc. Please see the documentation of tocloft.

\documentclass{book} \usepackage[dutch]{babel} \usepackage{tocloft} \begin{document} \tableofcontents \addtocontents{toc}{\begingroup\protect\setlength{\protect\cftsecindent}{-\leftmargin}} \section*{Inleiding} \addcontentsline{toc}{section}{\protect\numberline{}Inleiding}% \section*{Voorword} \addcontentsline{toc}{section}{\protect\numberline{}Voorword} \addtocontents{toc}{\endgroup} \clearpage \chapter{Context} \section{Het bedrijf} \end{document} 

enter image description here

1
  • @user1213904: You're welcome! Happy TeXing. Commented Feb 24, 2017 at 14:07

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.