Page LayoutIndent contents line of table of content

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Jack1234567
Posts: 3
Joined: Fri Feb 08, 2019 10:33 am

Indent contents line of table of content

Post by Jack1234567 »

Hi there,

I used the following formatting to include apa references in my report, importing it from Mendeley.

% REFERENCES
\bibliographystyle{apacite}
\bibliography{Library.bib}

It automatically included a line in my table of content, as you can see below. However, I want to tab (indent) the reference line, in order to align it with the rest of the sections (summery, acknowledgement, etc.). Does anyone know how I can fix this problem?
TOC.PNG
TOC.PNG (35.94 KiB) Viewed 5717 times

ps. when I add another section line to my table of content, I get two references lines.
\addcontentsline{toc}{section}{\numberline{}References}
TOC 2.PNG
TOC 2.PNG (36.58 KiB) Viewed 5717 times

Thank you!!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Indent contents line of table of content

Post by Stefan Kottwitz »

Hi Jack,

welcome to the forum!

It seems you have somewhere else in your code such an \addcontentsline already, but without that \numberline{}. That happens for example if you simply use the tocbibind package.

Quick patch, at the end of your document preamble, so right before \begin{document}:

Code: Select all

\let\origaddcontentsline\addcontentsline
\renewcommand{\addcontentsline}[3]{\origaddcontentsline{#1}{#2}{\numberline{}#3}}
Stefan
LaTeX.org admin
Jack1234567
Posts: 3
Joined: Fri Feb 08, 2019 10:33 am

Indent contents line of table of content

Post by Jack1234567 »

Hi Stefan,

Thank you so much, this was very much of a help. Fixed the 'reference' problem.
However, next problem the appendix's have indented now. Do you also know how to get them aligned with the numbers?

Excuse me, just started working with Latex, so it's all a bit new to me.
TOC 3.PNG
TOC 3.PNG (53.23 KiB) Viewed 5708 times
Thank you!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Indent contents line of table of content

Post by Stefan Kottwitz »

You could revert that change after \bibliography and before the appendix:

Code: Select all

\let\addcontentsline\origaddcontentsline
Stefan
LaTeX.org admin
Jack1234567
Posts: 3
Joined: Fri Feb 08, 2019 10:33 am

Indent contents line of table of content

Post by Jack1234567 »

Perfect, thank you!
Post Reply