Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to show the bibliography in the TOC.

This is how far I got:

\clearpage
\def \nextsection{\thesection + 1}
\addcontentsline{toc}{section}{\nextsection Bibliography}
\printbibliography
\thispagestyle{empty}
  • \clearpage For some reason, the page number wasn't right without this. It would seem, the bibliography command alone won't increment it.

  • \def ... This is meant to return an integer. Actually, it returns a string (for example, 11 + 1), so the computation is not performed; the arithmetic is taken literally. I could replace this by the section I know it to be, but that would break if I ever were to add another section (assuming the bibliography would remain last). Yet another problem (while a detail) is the incorrect spacing of the TOC: see the screenshot below.

  • \thispagestyle{empty} As I'd like the page number not to show up on the bibliography page (works).

Also, I'd say "Bibliography" is a bit pretentious. Is there a way to change it to, say, "References" or "Sources"? This is actually related to this question: perhaps that way, I could name it to use the "increase section" function so that it will show up as (say) "12. Sources" both in the TOC and as page header?

Edit

As for the name, and header, this is an improvement:

\clearpage
\renewcommand\bibname{12 Sources}
\addcontentsline{toc}{section}{\bibname}

Still: explicit section number (no increment), TOC align thing, and, for a clickable TOC, you don't get to the correct place by clicking the Sources line (probably because of the \clearpage).

Edit 2: MWE

OK, check out the MWE here.

Files: Makefile; x.bib, x.tex; and x.pdf

Problems, already described above and in comments: Increment, TOC align, clickable, consistent header looks.

incorrect spacing

share|improve this question
    
Which document class do you use? –  Kurt Mar 4 '13 at 0:49
    
@Kurt: report –  Emanuel Berg Mar 4 '13 at 1:01
    
To change the section header of the bibliography when using the report document class, issue a command such as \renewcommand\bibname{Sources} (or whatever alternative title you prefer). –  Mico Mar 4 '13 at 3:07
    
@Mico: Yes, that's much better: see the edit! –  Emanuel Berg Mar 4 '13 at 3:30
    
Please create a complete MWE (minimum working example) of what you're trying to achieve. I'm afraid that the code snippets you've provided so far create a rather incomplete picture of your objectives. For instance, it's only in the follow-up edit that you mention (implicitly) that you're also using the hyperref package. –  Mico Mar 4 '13 at 3:33
show 4 more comments

2 Answers

up vote 2 down vote accepted

You can define the header behavior of the bibliography using biblatex commands.

What you have to do is to define the header like this

\defbibheading{headername}[\bibname]{%
  % new definition
}

and if you use the same name as the default: bibliography you don't have to do anything to the \printbibliography macro. If you chose to change the name (like in this example) you should pass it to the macro like this: \printbibliography[heading=headername]. And that should do the trick.

With this you don't need to add the bibliography to the ToC because it's done automatically when you define it in the header as a section.

\documentclass[a4paper, twoside, 12pt]{report}

\usepackage{filecontents}

\begin{filecontents}{x.bib}
@Book{luger,
author = {George Luger},
title = {Artificial Intelligence},
subtitle = {Structures and Strategies for Complex Problem Solving},
year = {2009}}
\end{filecontents}

\usepackage[colorlinks]{hyperref}

\usepackage[style=authortitle-icomp,backend=biber]{biblatex}
\addbibresource{x.bib}

\usepackage{scrextend}
\deffootnote[1.8em]{0pt}{1.6em}{\makebox[1.8em][l]{\thefootnotemark.}}
\renewcommand{\footnoterule}{%
  \kern -3pt
  \hrule width \textwidth height 1pt
  \kern 2pt
}

% Note that you can name it bibliography and overwrite the default
\defbibheading{mybibliography}[\bibname]{%
\section{#1}}


\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
\renewcommand\thesection{\arabic{section}}

\begin{document}

\tableofcontents
\thispagestyle{empty}

\section{First section}
Test of note.\footcite[127]{luger}

\section{Second section}
Test of paragraph for TOC.

\clearpage
\renewcommand\bibname{Sources}
\printbibliography[heading=mybibliography]
\thispagestyle{empty}

\end{document}
share|improve this answer
    
This works great! Only, I had to put \newbibmacro{in:}{} to get it to show up in the ToC. Those other problems: align, counting, hyperref, header size, new header name - well, you aced the quiz, if there ever was one! –  Emanuel Berg Mar 5 '13 at 0:29
add comment

You gave no MWE so it is a little bit a guess what you want.

I think you want the bibliography listed numbered in the table of content.

Please try this MWE:

\RequirePackage{filecontents}        % loading package filecontents
% writing file \jobname.bib, for example mb-bibtex.bib.
\begin{filecontents*}{\jobname.bib}
@Book{companion,
  author    = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
  title     = {The LaTeX Companion},
  edition   = {1},
  publisher = {Addison-Wesley},
  location  = {Reading, Mass.},
  year       = {1994}
}
@Book{adams,
  title     = {The Restaurant at the End of the Universe},
  author    = {Douglas Adams},
  series    = {The Hitchhiker's Guide to the Galaxy},
  publisher = {Pan Macmillan},
  year      = {1980}
}
\end{filecontents*}


\documentclass{report}

\usepackage[numbers]{natbib}         % bibliography style
\usepackage[colorlinks]{hyperref}    % better urls in bibliography

\begin{document}

\tableofcontents

\chapter{test}
Test of bibliography: 
The \LaTeX{} companion~\cite{companion}, the funny book of Adams~\cite{adams}.

\clearpage
\chapter{Bibliography}
\bibliographystyle{plainnat}  % needs package natbib
\bibliography{\jobname}       % uses \jobname.bib, according to \jobname.tex
\end{document}

You will get a numbered Bibliography with proper space between number and text. If you need another header change \chapter{Bibliography} to what you want.

I hope I didn't missunderstand you.

You can change my MWE as follows (shows only the changed part) to use biblatex:

\documentclass{report}

%\usepackage[numbers]{natbib}         % bibliography style
\usepackage[style=authortitle,backend=bibtex]{biblatex}
\bibliography{\jobname}       % uses \jobname.bib, according to \jobname.tex
\usepackage[colorlinks]{hyperref}    % better urls in bibliography

\begin{document}

\tableofcontents

\chapter{test}
Test of bibliography: 
The \LaTeX{} companion~\cite{companion}, the funny book of Adams~\cite{adams}.

\clearpage
\chapter{Bibliography}
\printbibliography        % Use with biblatex

\end{document}
share|improve this answer
    
This: \usepackage[numbers]{natbib} gets me an error, saying bibhang is already defined? –  Emanuel Berg Mar 4 '13 at 2:11
    
My MWE used natbib but the MWE works also without. Just comment the line with natbib and change the bibliography style from plainnat to plain. As I do not know what you are using in your document (packages and definitions) I can not tell you were the error with bibhang comes from. Try to find out with copying package after package into the MWE. Copy one, compile. Error? You found the problem. No Error? Go on with the next package ... –  Kurt Mar 4 '13 at 2:44
    
Did you get the error from compiling my MWE? That should not be, it should compile without an error. If not you should update your system. –  Kurt Mar 4 '13 at 2:47
1  
Please check this link to learn to build a minimal working example (MWE). A MWE would show (without saying it) that you are using biblatex. Take my MWE, change it (include the way you build your bibliography by adding used packages (biblatex, something else?, the used bibliography style) and compile it. –  Kurt Mar 4 '13 at 3:11
1  
No problem, we all have to learn every day. –  Kurt Mar 4 '13 at 3:37
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.