0

I'm trying to achieve the following with my current table of contents. I want to remove the vertical spacing for specific items e.g. Declaration, Abstract etc.

Then I want everything aligned left, with no indentation for the numbering. I'm using the standard

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[11pt, oneside]{book} %reminder to add twoside command when printing
\pagestyle{plain}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Packages to use. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{2212}{-}% support older LaTeX versions

\usepackage[a4paper,left=30mm,right=20mm,top=20mm,bottom=20mm]{geometry}
\usepackage{float}
\usepackage{rotating}
\usepackage{parskip}
\usepackage{rotating}
\usepackage{upgreek}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}%
\usepackage{multirow}
\usepackage{tocbasic}
\usepackage{expl3}
\usepackage{tocbibind}


%%%%%%%%%%%%%%%%%
% Setup line spacing for document %
%%%%%%%%%%%%%%%%%
\usepackage{setspace}
%\singlespacing
\onehalfspacing
%\doublespacing
%\setstretch{1.1}


%%%%%%%%%%%%%%%%%
% THE BEGINNING %
%%%%%%%%%%%%%%%%%
\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\addcontentsline{toc}{chapter}{Dedication}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlah}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlahBlah}
\blindtext
\blinddocument
\end{document}

To add the extra items to the TOC and \tableofcontents for the creation of my TOC. Current structure

Any assistance will be greatly appreciated.

  • 1
    What class are you using? – nox Jul 2 '18 at 22:41
  • \documentclass[11pt, oneside]{book} %reminder to add twoside command when printing \pagestyle{plain} – user2459813 Jul 2 '18 at 22:46
  • Any help guys? The class is book. – user2459813 Jul 3 '18 at 5:47
3

Update

Now there is a MWE in the question and I know that TOC entries for TOC, LOF and LOT etc. are required. But I do not understand what the comment

The alignment between the numbering and title needs to be in line as well

means. So it is still a guess what the desired result is.

\documentclass[11pt,a4paper,oneside]{book}
\usepackage{blindtext}% only for dummy text
\pagestyle{plain}

\usepackage[utf8]{inputenc}
\usepackage[margin=20mm,left=30mm]{geometry}
\usepackage{parskip}
\usepackage[onehalfspacing]{setspace}

\usepackage{tocbibind}
\usepackage{tocbasic}
\usepackage{expl3}

\usepackage{hyperref}% <- should be the last package

\ExplSyntaxOn
  \clist_map_inline:nn
    {chapter,section,subsection,subsubsection,paragraph,subparagraph}
    {\DeclareTOCStyleEntry[indent=0pt,numwidth=3.8em]{tocline}{#1}}
  \clist_map_inline:nn
    {figure,table}
    {\DeclareTOCStyleEntry[indent=0pt]{tocline}{#1}}
\ExplSyntaxOff

\DeclareTOCStyleEntry[%
  level=\chaptertocdepth,%
  beforeskip=0pt plus .2pt,%
  indent=0em,%
  numwidth=3.8em,%
  entryformat=\textbf,%
  pagenumberformat=\textbf,%
  linefill=\hfill
]{tocline}{fmchapter}

\makeatletter
\let\l@origchapter\l@chapter
\newcommand*\usefmchapter{% define switch to fmchapter entry
  \addtocontents{toc}{%
    \protect\addvspace{1em plus 1pt}% additional space in TOC before the first fmchapter entry
    \protect\let\protect\l@chapter\protect\l@fmchapter
  }%
}
\newcommand*\useorigchapter{% define switch to original chapter entry
  \addtocontents{toc}{%
    \protect\let\protect\l@chapter\protect\l@origchapter
  }%
}
\makeatother

\begin{document}

\usefmchapter% <- switch
\tableofcontents
\listoffigures
\listoftables
\addcontentsline{toc}{chapter}{Dedication}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlah}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlahBlah}
\blindtext

\useorigchapter% <- switch
\blinddocument

\usefmchapter% <- switch
\addcontentsline{toc}{chapter}{Conclusion}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlah}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlahBlah}
\blindtext
\end{document}

Result:

enter image description here

Note that you can/have to adjust numwidth=3.8em to your needs.

But if you want

enter image description here

then you have to use the value of numwidth for indent of fmchapter:

\DeclareTOCStyleEntry[%
  level=\chaptertocdepth,%
  beforeskip=0pt plus .2pt,%
  indent=3.8em,% <- changed
  numwidth=3.8em,%
  entryformat=\textbf,%
  pagenumberformat=\textbf,%
  linefill=\hfill
]{tocline}{fmchapter}

Original answer

Unfortunaly there is no MWE in the question, so it is only a guess. The following suggestion uses package tocbasic to declare an additional entry style in TOC:

\documentclass[11pt,oneside]{book}
\pagestyle{plain}

\usepackage{tocbasic}
\usepackage{expl3}

\ExplSyntaxOn
  \clist_map_inline:nn
    {chapter,section,subsection,subsubsection,paragraph,subparagraph}
    {\DeclareTOCStyleEntry[indent=0pt]{tocline}{#1}}
\ExplSyntaxOff

\DeclareTOCStyleEntry[%
  level=\chaptertocdepth,%
  beforeskip=0pt plus .2pt,%
  indent=0pt,%
  numwidth=1.5em,%
  entryformat=\textbf,%
  pagenumberformat=\textbf,%
  linefill=\hfill
]{tocline}{fmchapter}

\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\chapter*{Declaration}\addcontentsline{toc}{fmchapter}{Declaration}
\blindtext
\chapter*{Abstract}\addcontentsline{toc}{fmchapter}{Abstract}
\blindtext
\chapter*{Dedication}\addcontentsline{toc}{fmchapter}{Dedication}
\blindtext
\blinddocument
\end{document}

Result:

enter image description here

  • MWE added, the \clist_map_inline:nn provides an error on my compile. – user2459813 Jul 3 '18 at 6:48
  • Your answer works but doesn't fully do what I want. The alignment between the numbering and title needs to be in line as well. How do I make use of the fmchapter \addcontentsline when using \usepackage{tocbibind} – user2459813 Jul 3 '18 at 6:52
  • 1
    That is the problem of missing MWEs. See my updated answer. But I am still not sure how the desired result looks like. – esdd Jul 3 '18 at 8:09
  • Your final update was simply brilliant. Thank you very much, you've interpreted what I wanted exactly and it works very well! Thank you very much! – user2459813 Jul 4 '18 at 7:09

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.