4

The deadline for my final senior design report is a few weeks away and I'm trying to migrate away from Word (which I used to finish my previous reports) to Latex. I have most of the formatting done, but despite spending several hours, I'm not able to get the Table Of Contents formatting correct. Does anyone know how I can go about making my ToC look like this?

Sample ToC

The above is a picture from my preliminary report. The final report has specifications exactly the same as the one listed above.

The closest I've gotten is by using this:

\usepackage[tocflat]{tocstyle}
%Formatting of the TOC
\makeatletter
\renewcommand
\tableofcontents
{
  \begin{center}
  \begingroup
  \fontsize{12pt}{28.8pt}\selectfont
  \textbf{CONTENTS}
  \endgroup
  \\~\\
  \@starttoc{toc}%
  \end{center}
}
\makeatother

However, this doesn't fix the Section-SubSection-SubSubSection indentation and formatting issues.

As far as non-obvious formatting restrictions go, I'm required to have 2 (1.5 spaced) lines between the title (i.e. "CONTENTS") and the first two headers (i.e. "TABLES" and "FIGURES") and a one-line (1.5 spaced) space between "FIGURES" and the start of the remainder of the ToC.

Help in this matter would be greatly appreciated!

4
  • The indentation should be there automatically, as far as I know...
    – Alenanno
    Apr 17, 2016 at 9:18
  • 1
    Welcome, personally, i wouldn't spend time to convert a document to LaTeX and force it to look like a Word document. I would just stick to Word.
    – Johannes_B
    Apr 17, 2016 at 9:45
  • Are the sections really numbered 1.0, 2.0, 3.0, etc? Would 1, 2, 3 be acceptable?
    – Mico
    Apr 17, 2016 at 10:18
  • 1
    The arguments of \fontsize don't take dimensional expressions. They are numbers only. (The first one to determine the font size and second one sets the baseline height.) However, the implicit unit is pt as you rightly assumed.
    – Ruben
    Apr 17, 2016 at 14:09

2 Answers 2

3
\documentclass{article}
\usepackage{titletoc}
\titlecontents{section}[2.3em]
  {}
  {\bfseries\contentslabel[\thecontentslabel.0]{2em}\MakeUppercase}
  {\hspace*{-2.3em}\bfseries\MakeUppercase}
  {\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}[4.6em]
  {}
  {\bfseries\contentslabel{2em}}
  {\hspace*{-2.3em}\bfseries}
  {\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsubsection}[6.9em]
  {}
  {\bfseries\contentslabel{2em}\itshape\space}
  {\hspace*{-2.3em}\bfseries}
  {\titlerule*[1pc]{.}\contentspage}

\makeatletter
\renewcommand\tableofcontents{%
  \section*{\centerline{\MakeUppercase{\contentsname}}
    \@mkboth
      {\MakeUppercase\contentsname}
      {\MakeUppercase\contentsname}
  }%
  \@starttoc{toc}%
}
\makeatother

\begin{document}

\tableofcontents
\clearpage

\pagenumbering{roman}
\section*{Tables}
\addcontentsline{toc}{section}{Tables}
\addtocontents{toc}{\vspace{1em}}
\clearpage

\pagenumbering{arabic}
\section{Introduction}
\section{Design project background}
\subsection{Problem definition}
\subsubsection{Firmware code}

\end{document}

output_crop

7
  • Note: titletoc destroys several KOMA features.
    – Johannes_B
    Apr 17, 2016 at 11:45
  • @Johannes_B -- wow, good to know! Which particular features are afflicted? And is this documented somewhere? (The titlesec docu, for instance, does not mention it.)
    – Ruben
    Apr 17, 2016 at 11:54
  • @Johannes_B -- btw: I realized that the OP does not require scrartcl. The other answer just used it and I followed blindly :) As my answer obviously works best with the standard classes I just changed it to article.
    – Ruben
    Apr 17, 2016 at 11:56
  • titlesec and tocbibind re bd with KOMA, titletoc seems to be fine. t least the few things i just tested.
    – Johannes_B
    Apr 17, 2016 at 12:23
  • @Johannes_B -- Well, I used titletoc features only in this solution anyways. Thank you though! I'll keep in mind that titlesec and tocbibind are bad with the KOMA classes.
    – Ruben
    Apr 17, 2016 at 14:04
0

I'm not entirely sure what your indentation problem was, but I guess this might be what you were aiming for...!

\documentclass[a4paper, numbers=noenddot]{scrartcl}

\usepackage{tocloft}
\usepackage[tocflat]{tocstyle}
% Formatting of the TOC

\begin{document}

\tableofcontents
\newpage

\section*{tables}
\addcontentsline{toc}{section}{tables}
\cftaddtitleline{toc}{section}{123}{\thepage}
\addtocontents{toc}{\vskip12pt}

\section{introduction}
\section{design...}
\subsection{problem...}
\subsection{needs...}


\appendix
\begingroup
    \addtocontents{toc}{\vskip12pt}
    \section{references}
    \section{relevant...}
    \section{bill...}
\endgroup

\end{document}

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.