1

I need to include my table of contents in my table of contents itself. My table of contents starts at page II but appears as III (the last page). I used the package \tocbibind but then it appears as chapters which I do not want. I want it to appear as a section. I´m still a beginner so I am very unsure on how to include something in the table of contents.

\documentclass[a4paper, 12pt, oneside, nenglish]{scrreprt}
\usepackage[paper=a4paper,left=30mm,right=15mm,top=20mm,bottom=25mm]{geometry}\pagestyle{plain}

\usepackage[pdf]{pstricks} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage[T1]{fontenc} \usepackage{graphicx, subfigure} \graphicspath{{img/}} \usepackage{fancyhdr} \usepackage{lmodern} \usepackage{color} \usepackage{transparent} \usepackage{float} \usepackage{setspace} \restylefloat{figure} \usepackage{tikz} \usepackage[locale=DE]{siunitx} \usepackage{cancel} \usepackage{pdfpages} \usepackage{textpos} \usepackage{blindtext} \usepackage{natbib} \usepackage{mdframed} \usepackage{tcolorbox} \usepackage{multicol} \usepackage{multirow} \usepackage{tocbasic}

\begin{document}

\pagestyle{plain} \pagenumbering{Roman} \tableofcontents \addcontentsline{toc}{section}{Contents} \listoffigures \addcontentsline{toc}{section}{List of Figures} \listoftables \addcontentsline{toc}{section}{List of Tables}

\chapter{Introduction}

bla bla

\chapter {results}

bla bla

\end{document}

Bettina
  • 11
  • 2
  • 1
    Welcome to TeX.SE! Please make your given code snippet be compilable, then we do not have to guess what you are doing ... And please do not use commands like \input because we do not have the inputed files to make your code compilable! – Mensch Mar 06 '24 at 09:24
  • 1
    Note that a package like tocbibind automatically adds to like lists to the toc nothing manual needed. A class like memoir has this build in – daleif Mar 06 '24 at 09:33
  • For standard classes see https://tex.stackexchange.com/q/106093/82917, using tocbibind as @daleif suggested. As he also pointed out memoir and KoMa classes have their own built-in mechanisms. – campa Mar 06 '24 at 09:35
  • Also related: https://tex.stackexchange.com/q/41897/277964 or https://tex.stackexchange.com/q/600162/277964 – cabohah Mar 06 '24 at 10:03
  • The solution depends, e.g., on the used class and also on packages already used to configure the table of contents, list of figures or similar lists. So please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. – cabohah Mar 06 '24 at 10:10

2 Answers2

0

You should simply use the options and configuration features, KOMA-Script provides. In this case class option listof=totoc and additionally tocbasic feature \setuptoc{toc}{totoc}:

\documentclass[12pt,listof=totoc]{scrreprt}
\usepackage[paper=a4paper,left=30mm,right=15mm,top=20mm,bottom=25mm]{geometry}

\usepackage[english]{babel} \usepackage[T1]{fontenc} \usepackage{lmodern}

\setuptoc{toc}{totoc}% nonsense, but you've asked for

\begin{document}

\pagenumbering{Roman} \tableofcontents \listoffigures \listoftables

\chapter{Introduction}

bla bla

\chapter {results}

bla bla

\end{document}

enter image description here

Note, that I've remove several irrelevant packages and not needed options.

Note also, that

  • usage of package fancyhdr results in a warning, that recommends to use scrlayer-scrpage instead;
  • from LaTeX 2018-04-01 \usepackage[utf8]{inputenc} is not longer needed;
  • usage of \restylefloat{figure} significantly changes the behaviour of figure environments;
  • loading of package tocbasic is not needed when using a KOMA-Script class, because the class already uses this package.

If you really want the ToC entries be section entries you should also make corresponding lists be sections instead of chapters:

\documentclass[12pt,listof=totoc,listof=leveldown]{scrreprt}
\usepackage[paper=a4paper,left=30mm,right=15mm,top=20mm,bottom=25mm]{geometry}

\usepackage[english]{babel} \usepackage[T1]{fontenc} \usepackage{lmodern}

\setuptoc{toc}{totoc,leveldown}

\begin{document}

\pagenumbering{Roman} \addchap{Contents and Other Lists} \tableofcontents \listoffigures \listoftables

\chapter{Introduction}

bla bla

\chapter {results}

bla bla

\end{document}

enter image description here

Using section level in the ToC for all not numbered chapters would also be possible but not recommended:

\documentclass[12pt,listof=totoc]{scrreprt}
\usepackage[paper=a4paper,left=30mm,right=15mm,top=20mm,bottom=25mm]{geometry}

\usepackage[english]{babel} \usepackage[T1]{fontenc} \usepackage{lmodern}

\setuptoc{toc}{totoc} \NewCommandCopy{\OriginalAddChapterTocEntry}{\addchaptertocentry} \renewcommand*{\addchaptertocentry}[2]{% \IfArgIsEmpty{#1}{\addsectiontocentry}{\OriginalAddChapterTocEntry}{#1}{#2}% }

\begin{document}

\pagenumbering{Roman}

\tableofcontents \listoffigures \listoftables

\chapter{Introduction}

bla bla

\chapter {results}

bla bla

\end{document}

enter image description here

cabohah
  • 11,455
0

\addcontentsline{toc} is a correct way to add things to toc.

Anyway, you're using a KOMA-Script class which provides many options to handle what you required.

\KOMAoptions{toc=listof}

adds lists of figures and tables to toc.

\setuptoc{lof}{leveldown}
\setuptoc{lot}{leveldown}

format lof and lot titles with \section (as the class is scrreprt).

\setuptoc{toc}{leveldown, totoc}

formats toc title with \section and include it to the toc itself.

You don't need to load tocbasic as it's used internally by scrreprt.

\documentclass[a4paper, 12pt, oneside, nenglish]{scrreprt}
\usepackage[paper=a4paper,left=30mm,right=15mm,top=20mm,bottom=25mm]{geometry}\pagestyle{plain}

\usepackage[pdf]{pstricks} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage[T1]{fontenc} \usepackage{graphicx, subfigure} \graphicspath{{img/}} \usepackage{fancyhdr} \usepackage{lmodern} \usepackage{color} \usepackage{transparent} \usepackage{float} \usepackage{setspace} \restylefloat{figure} \usepackage{tikz} \usepackage[locale=DE]{siunitx} \usepackage{cancel} \usepackage{pdfpages} \usepackage{textpos} \usepackage{blindtext} \usepackage{natbib} \usepackage{mdframed} \usepackage{tcolorbox} \usepackage{multicol} \usepackage{multirow}

\KOMAoptions{toc=listof}

\setuptoc{toc}{leveldown, totoc} \setuptoc{lof}{leveldown} \setuptoc{lot}{leveldown}

\begin{document}

\pagestyle{plain} \pagenumbering{Roman} \tableofcontents

\listoffigures

\listoftables

\chapter{Introduction}

bla bla

\chapter {results}

bla bla

\end{document}

jlab
  • 1,834
  • 1
  • 13