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 am adding a section with the bibliography references by using \addcontentsline in order to add a link to the table of contents. Unfortunately the link in the table of contents links to a wrong page, previous to the page with the bibliography.

How can I immediately place an anchor for a new section in table of contents?

\printbibliography[heading=offline,filter=offline]
\addcontentsline{toc}{section}{\bibname}
\printbibliography[heading=online,filter=online]
share|improve this question
    
How do you define the online heading? –  egreg Jan 21 '12 at 14:35
    
It's also important to know the document class. –  Marco Daniel Jan 21 '12 at 15:27

2 Answers 2

up vote 13 down vote accepted

The \printbibliography command indicates that you're using biblatex. To add bibliographies to the ToC with biblatex (without numbering them), normally one should add the heading=bibintoc option to \printbibliography. See section 3.6.7 of the biblatex manual for details.

As you seem to have defined a custom online heading, you may have to change its definition so that it resembles that of bibintoc (which is tailored to the document class and may be found in biblatex.def).

share|improve this answer

The following comments can be used more in general.

The main minimal example

The following example is the basis of the next steps.

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\defbibfilter{online}{ type=online }
\defbibfilter{offline}{ not type=online }
\begin{document}
\tableofcontents

\noindent\hrulefill

\section{foo}
\cite{companion} \& \cite{ctan}

\noindent\hrulefill

\printbibliography[filter=offline]

\noindent\hrulefill

\printbibliography[filter=online]

\end{document}

The next image shows the result.

enter image description here

We mention that the heading of the bibliographies are equal and not shown in the table of contents (toc).

Suppose you are using a standard class

First approach -- working with `biblatex` options

The first approach based on the idea that we only use the option provided by the package biblatex for the command \printbibliograpy.

First of all we want a special name for your heading. This can be done be the option title. So we simple set:

\printbibliography[filter=offline,title=Offline,]

\printbibliography[filter=online,title=Online,]

With this modification we doesn't have an entry in the toc. To provide an entry in the toc we can use the option heading. biblatexoffers different values for this option. Here a small range:

  • bibliography:
    • unnumbered -- no entry in toc -- chapter level (section for articles)
  • subbibliography:
    • unnumbered -- no entry in toc -- section level (subsection for articles)
  • bibintoc:
    • unnumbered -- entry in toc -- chapter level (section for articles)
  • subbibintoc:
    • unnumbered -- entry in toc -- section level (subsection for articles)
  • bibnumbered:
    • numbered -- entry in toc -- chapter level (section for articles)
  • subbibnumbered:
    • numbered -- entry in toc -- section level (subsection for articles)

Based on this information we can expand your examples as follows:

\printbibliography[filter=offline,title=Offline,heading=subbibintoc]

\printbibliography[filter=online,title=Online,subbibintoc]

The example demonstrate the first apprach:

\documentclass[varwidth]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\defbibfilter{online}{ type=online }
\defbibfilter{offline}{ not type=online }
\begin{document}
\tableofcontents

\noindent\hrulefill

\section{foo}
\cite{companion} \& \cite{ctan}

\noindent\hrulefill
\section{References}

\printbibliography[filter=online,title=Offline,heading=subbibintoc]

\noindent\hrulefill

\printbibliography[filter=online,title=Online,heading=subbibintoc]


\end{document}

enter image description here

Second approach - define your own header

In normal cases the standard option should be enough. However you can define your own special heading with the command \defbibheading. The standard syntax is

\defbibheading{⟨name⟩}[⟨title⟩]{⟨code⟩}

The defined heading can be used by the optional argument heading (see above).

We take an example. The heading should be unnumbered but with an entry in the toc:

\defbibheading{myheading}[\bibname]{%
 \begin{center}
  \hrulefill#1\markboth{#1}{#1}\hrulefill%
  \addcontentsline{toc}{subsection}{#1}%
 \end{center}%
}

Based on these heading in combination with the option title we can create the following example:

\documentclass[varwidth]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\defbibfilter{online}{ type=online }
\defbibfilter{offline}{ not type=online }
\defbibheading{myheading}[\bibname]{%
 \begin{center}
  \hrulefill#1\markboth{#1}{#1}\hrulefill%
  \addcontentsline{toc}{subsection}{#1}%
 \end{center}%
}
\begin{document}
\tableofcontents

\noindent\hrulefill

\section{foo}
\cite{companion} \& \cite{ctan}

\noindent\hrulefill
\section{References}

\printbibliography[filter=offline,title=Offline,heading=myheading]

\printbibliography[filter=online,title=Online,heading=myheading]


\end{document}

enter image description here

Suppose you are using a KOMA class

KOMA provides additional document class options to manipulate the heading of a bibliography. The benefit of this method you can set the option global. All options provided by KOMA are compatible with biblatex. The key of the document class is bibliography. A range of possibilities are listed below. Of course all listed approaches in the above section can be used in combination with KOMA.

  • notoc:
    • unnumbered -- no entry in toc -- chapter level (section for articles)
  • totoc:
    • unnumbered -- entry in toc -- chapter level (section for articles)
  • totocnumbered:
    • numbered -- entry in toc -- chapter level (section for articles)

Based of your main MWE here the modification:

\documentclass[bibliography=totoc]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\defbibfilter{online}{ type=online }
\defbibfilter{offline}{ not type=online }

\begin{document}
\tableofcontents

\noindent\hrulefill

\section{foo}
\cite{companion} \& \cite{ctan}

\noindent\hrulefill

\printbibliography[filter=offline,title=Offline]

\printbibliography[filter=online,title=Online]


\end{document}

enter image description here

Suppose you are using memoir

This is really simple. memoir creates an entry in the toc as default.

share|improve this answer

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.