TransWikia.com

References in table of contents

TeX - LaTeX Asked by Klaas on May 14, 2021

I´m struggling to format the entry for the references in my table of contents like the entry for the chapter.

My table of contents ("Inhalt") looks like this:
enter image description here

Obviously the second entry for "Literatur" is unneccessary.

I prepared an example wich looks like this:

documentclass[11pt,a4paper]{book} % Basisdokumentenklasse
usepackage[utf8]{inputenc}       % Standard for Linux
usepackage{ngerman}    % Fr Umlaute   
usepackage[hidelinks]{hyperref}     % links in PDF ohne Ksten (RSt 2017)
usepackage{apacite} 

% Das eigentliche Dokument
begin{document}

% Inhaltsverzeichnis
renewcommand{contentsname}{Inhalt} % Es soll nicht Inhaltsverzeichnis heien, sondern Inhalt
tableofcontents        % Inhaltsverzeichnis einbinden


chapter{todo}
cite<vgl.>{test}
 
% Schlielich Literatur
renewcommand{bibname}{Literatur}        
bibliographystyle{apacite}
addcontentsline{toc}{chapter}{Literatur}
bibliography{bibliographie}  



end{document}

My bibliographie.bib looks like this:

% Encoding: UTF-8

@Article{test,
  author  = {Dr. Britta A. Mester},
  title   = {Auswirkungen der DSGVO auf die IT},
  journal = {Wirtschaftsinformatik & Management},
  year    = {2017},
  volume  = {4},
  pages   = {12--14},
}

@Comment{jabref-meta: databaseType:bibtex;}

I only want to keep the first entry "Literatur" in my table of contents. How do I achieve this?

One Answer

If at all possible I would try to avoid using manual addcontentslines in the document body: If not used carefully, they may end up adding entries with wrong page numbers to the table of contents.

Often it is possible to avoid addcontentsline by using certain package options, with additional packages or with preamble code.

apacite has a very clever heuristic to decide whether or not to typeset its bibliography as a section or a chapter. When used in a class that has chapters (like book), apacite detects if the bibliography is typeset in the backmatter or in the mainmatter. In the mainmatter the bibliography is typeset as a section (working under the assumption that each chapter has its own bibliography). In the backmatter the bibliography is typeset as a chapter (here the assumption is that this is the bibliography for the whole document).

So you can get what you want, if you remove addcontentsline and issue backmatter before the bibliography.

documentclass[11pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage[ngerman]{babel}
usepackage[T1]{fontenc}
usepackage[hidelinks]{hyperref}
usepackage{apacite}

usepackage{etoolbox}

apptocaptionsngerman{%
  renewcommand{contentsname}{Inhalt}%
  renewcommand*{APACrefatitle}[2]{#1}%
}

begin{filecontents}{jobname.bib}
@Article{test,
  author  = {Britta A. Mester},
  title   = {Auswirkungen der DSGVO auf die IT},
  journal = {Wirtschaftsinformatik & Management},
  year    = {2017},
  volume  = {4},
  pages   = {12--14},
}
end{filecontents}

begin{document}
tableofcontents

chapter{todo}
cite<vgl.>{test}
 
backmatter
renewcommand{bibname}{Literatur}%
bibliographystyle{apacite}
bibliography{jobname}
end{document}

ToC with "Literatur" as a chapter.

Alternatively, you can turn off apacite's heuristic and force a chapter bibliography with the option nosectionbib.

documentclass[11pt,a4paper]{book}
usepackage[utf8]{inputenc}
usepackage[ngerman]{babel}
usepackage[T1]{fontenc}
usepackage[hidelinks]{hyperref}
usepackage[nosectionbib]{apacite}

usepackage{etoolbox}

apptocaptionsngerman{%
  renewcommand{contentsname}{Inhalt}%
  renewcommand*{APACrefatitle}[2]{#1}%
}

begin{filecontents}{jobname.bib}
@Article{test,
  author  = {Britta A. Mester},
  title   = {Auswirkungen der DSGVO auf die IT},
  journal = {Wirtschaftsinformatik & Management},
  year    = {2017},
  volume  = {4},
  pages   = {12--14},
}
end{filecontents}

begin{document}
tableofcontents

chapter{todo}
cite<vgl.>{test}
 
renewcommand{bibname}{Literatur}%
bibliographystyle{apacite}
bibliography{jobname}
end{document}

As mentioned in my comment under your question I would replace usepackage{ngerman} with usepackage[ngerman]{babel}, so that is what I did in the MWE.

I also loaded usepackage[T1]{fontenc} for proper hyphenation/line breaking of non-ASCII characters (äöüß), see Why should I use usepackage[T1]{fontenc}?.

It is very unusual to include academic titles and degrees in the bibliography, so I replaced author = {Dr. Britta A. Mester},, which would (incorrectly) show up as

Mester, D. B. A.

with

author  = {Britta A. Mester},

I also moved the redefinition of contentsname to captionsgerman, which is where babel keeps its language strings.

Finally, I told apacite to avoid applying sentence case in the example, since we are dealing with a German document where turning 'Auswirkungen der DSGVO auf die IT' into

Auswirkungen der dsgvo auf die it

would be wrong. (Ideally this would be language-dependent, but I don't think apacite supports that. See also change reference appearance of apacite (but only for german language))

Note that apacite generates citations according to the 6th edition of the APA manual. The current edition of the APA manual is the 7th edition. In the LaTeX world 7th-ed. APA style is only implemented by biblatex-apa. See Is there a way to apply Apa 7th references and citation style in latex?.

Correct answer by moewe on May 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP