0

I am generating a document with multiple custom tables and sections that don't follow standard numbering and am using \addcontentsline to place them in the TOC as below.

\documentclass[12pt]{report}

\pagenumbering{roman}

\begin{document}
%begin revision history
    \addcontentsline{toc}{section}{REVISION HISTORY}
    \begin{raggedright}
    {\bf\LARGE{REVISION HISTORY}}\\
    \rule{\linewidth}{0.5pt}\\
    Add Revision History. If initial release, delete page.\\
%end revision history
\bigskip %replace \newpage for code snippet
%begin table of contents
    \addcontentsline{toc}{section}{TABLE OF CONTENTS}
    {\bf\LARGE{TABLE OF CONTENTS}}\\
    \rule{\linewidth}{0.5pt}\\
    \end{raggedright}
    \begin{center}
    \makeatletter
    \@starttoc{toc}% Print Table of Contents
    \makeatother
    \end{center}
%end table of contents
\bigskip %replace \newpage for code snippet
%begin list of figures
    \addcontentsline{toc}{section}{LIST OF FIGURES}
    \begin{raggedright}
    {\bf\LARGE{LIST OF FIGURES}}\\
    \rule{\linewidth}{0.5pt}\\
    Add List of Figures. If not utilized, delete page.
    \end{raggedright}
\end{document}

The code above produces a table of contents with the first item as I would expect and the next two indented, even though they are the same depth.

TOC Indent

Why are second and third lines of the TOC indented and how do I fix that?

5
  • 1
    Is there a reason you're not just using \section{REVISION HISTORY}? Custom tables and section numbering aren't too hard to fix.
    – Teepeemm
    May 13 '20 at 15:46
  • 1
    you are missing the chapter entry. Why are you using the report class and then only sections? May 13 '20 at 15:56
  • @UlrikeFischer I'm pretty new to LaTeX, but report had templating that matched closest with the MSWord template I'm imitating. I guess I can go back to article and try to reformat there. I'll also try swapping to chapters and see how that goes.
    – Matt
    May 13 '20 at 16:05
  • @Teepeemm my actual document has a mix of numbered and unnumbered sections, so I would be using \section* and then still have to use \addcontentsline.
    – Matt
    May 13 '20 at 16:05
  • Don't use \bf which was deprecated over 25 years ago. Use either {\bfseries text} or \textbf{<text>}. May 13 '20 at 16:43
0

I discovered accidentally that wrapping the @starttoc{toc} in a centered environment is what was causing the odd indent. Removing the \begin and \end {center} lines fixed the issue.

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.