General ⇒ Header in middle of TOC
Header in middle of TOC
Abstract ........................... i
Table of contents..................... ii
...
Glossary.................................. iv
Section
1 Introduction ......................... 1
2 Background ......................... 10
2.1 Details .......................... 12
Bibliography ................................. 659
My question is how do I deal with that Section header in the middle of the TOC? I hoped tocloft would help me, but it doesn't seem to do what I need. What I did was added the section header as \addcontentsline{toc}{part}{SECTION} hoping that I could use tocloft to style it appropriately (I don't use the 'part' entity anywhere else in my document).
The problem I have even with this 'part' hack is that the sections above "Section" are indented as the sections below "Section", but somehow I need those to be flush left. A even more horrible hack would be to add them as subsubsections (which I don't use anywhere else) and style subsubsections appropriately....
Edit: Well, that's what I did. I used tocloft to change the properties of 'subsubsection' for the non-numbered sections, and to change the properties of 'part' for the Section header. Good thing I didn't actually need 'part' or 'subsubsection' anywhere else... does anyone have a better method?
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Header in middle of TOC
runderwo wrote: I hoped tocloft would help me, but it doesn't seem to do what I need
in fact, tocloft does what you need:
Code: Select all
\cftpagenumbersoff{part}
\cftaddtitleline{toc}{part}{Section}{}
Re: Header in middle of TOC
I didn't notice the indentation didn't show up in my original post. Sorry about that. Any non-numbered section should be flush left, and any numbered section should be indented.
Is there any way to do that without having to use tocloft to style yet another distinct class for the purpose? Basically, a way to disable TOC indent until a particular section is reached, enable it, then disable it when the last numbered section is passed.
Header in middle of TOC
Code: Select all
\documentclass{article}
\usepackage{tocloft}
\renewcommand{\cftpartpagefont}{\bfseries \small}
\renewcommand{\cftpartfont}{\bfseries \small}
\setlength{\cftsecindent}{10pt}%change the sections indentation
\begin{document}
\begin{abstract}
This is the abstract.
\end{abstract}
\addcontentsline{toc}{part}{Abstract}
\clearpage
\tableofcontents
\addcontentsline{toc}{part}{Table of Contents}
\clearpage
\cftpagenumbersoff{part}
\cftaddtitleline{toc}{part}{Section}{}
\section{First section}
\section{Second section}
\begin{thebibliography}{99}
\addcontentsline{toc}{part}{Bibliography}
\bibitem{key1} First Bibitem.
\end{thebibliography}
\end{document}
Edit: I originally posted a wrong solution.
Header in middle of TOC
Code: Select all
\documentclass{article}
\makeatletter
\renewcommand{\@dotsep}{200}%get rid of dotted lines for subsections
\makeatother
\begin{document}
\contentsline{section}{\Large Table of contents}{}
\protect\addvspace{35pt}%add space between title and first entry
\contentsline{section}{Abstract}{i}
\contentsline{section}{Table of contents}{ii}
\contentsline{section}{Glossary}{iv}
\contentsline{section}{Section}{}
\contentsline{section}{\numberline{1}Introduction}{1}
\contentsline{section}{\numberline{2}Background}{10}
\contentsline{subsection}{\numberline{2.1}Details}{12}
\contentsline{section}{Bibliography}{659}
\newpage
\end{document}