3

biblatex' backref option can only be set globally by default. What I want to achieve is to turn it off and on for individual bibliographies. So that one printbibliography has backref enabled and other one does not. Is this possible?

EDIT

Here's a MWE. The goal would be to have backref enabled for the filmography viz. the second bibliography.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\usepackage[style=fiwi,]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{bib.bib}
@incollection{Muller.M:2014a,
Address = {Baden-Baden},
Author = {Müller, Martin},
Booksubtitle = {Zum Staatsverständnis in den klassischen Utopien},
Booktitle = {Idealstaat oder Gedankenexperiment?},
Editor = {Schölderle, Thomas},
Pages = {287--304},
Publisher = {Nomos},
Title = {Richard Rortys \emph{Contingency, Irony, and Solidarity} (1989)},
Year = {2014}}
@movie{Kubrick.S:1964,
Address = {GB},
Author = {Kubrick, Stanley},
Shorttitle = {Dr. Strangelove},
Subtitle = {Dr. Seltsam oder Wie ich lernte, die Bombe zu lieben},
Title = {Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb},
Year = {1964}
}
\end{filecontents*}
\addbibresource{bib.bib}
\begin{document}
\cite{Muller.M:2014a}
\citefilm{Kubrick.S:1964}
\printbibliography[nottype=movie]
\newrefcontext[sorting=title]
\printbibliography[type=movie]
\end{document}
  • Can you share a bit more about your setup and intentions? How are the bibliographies separated (different refsegments, refsections, some filter ...)? An MWE would also not go amiss, so we have something to play around, even if the question doesn't strictly need one. – moewe Dec 20 '16 at 8:36
  • Thanks for clarifying things. I already have some ideas and will definitely have a look at this later if it is not answered then already. – moewe Dec 20 '16 at 8:50
1

There are several ways you can do this.

First of all, enable backref=true globally.

If you then only want movies to have a backref, modify the macro accordingly.

\renewbibmacro*{pageref}{%
  \ifboolexpr{not test {\iflistundef{pageref}} and test {\ifentrytype{movie}}}
    {\printtext[parens]{%
       \ifnumgreater{\value{pageref}}{1}
         {\bibstring{backrefpages}\ppspace}
         {\bibstring{backrefpage}\ppspace}%
       \printlist[pageref][-\value{listtotal}]{pageref}}}%
   {}}

Using this method the backref does not depend on the bibliography, but on the entry type (in your MWE the two coincide, maybe that is what you want in general, maybe not).


Alternatively, you suppress backrefs in the next bibliography with

\AtNextBibliography{\renewbibmacro*{pageref}{}}
\printbibliography[nottype=movie]

or you go the other way round and erase the pageref definition, but restore it for the relevant bibliography

\savebibmacro{pageref}
\renewbibmacro*{pageref}{}

\begin{document}
\cite{Muller.M:2014a}
\citefilm{Kubrick.S:1964}

\printbibliography[nottype=movie]

\newrefcontext[sorting=title]
\AtNextBibliography{\restorebibmacro{pageref}}
\printbibliography[type=movie]
\end{document}

Unfortunately, \printbibliography has no other precode argument that we could use.

The following is a proof of concept that gives us pre and postcode where we can execute arbitrary code directly from \printbibliography.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{csquotes}
\usepackage[style=fiwi,backref=true]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@incollection{Muller.M:2014a,
Address = {Baden-Baden},
Author = {Müller, Martin},
Booksubtitle = {Zum Staatsverständnis in den klassischen Utopien},
Booktitle = {Idealstaat oder Gedankenexperiment?},
Editor = {Schölderle, Thomas},
Pages = {287--304},
Publisher = {Nomos},
Title = {Richard Rortys \emph{Contingency, Irony, and Solidarity} (1989)},
Year = {2014}}
@movie{Kubrick.S:1964,
Address = {GB},
Author = {Kubrick, Stanley},
Shorttitle = {Dr. Strangelove},
Subtitle = {Dr. Seltsam oder Wie ich lernte, die Bombe zu lieben},
Title = {Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb},
Year = {1964}
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\savebibmacro{pageref}
\renewbibmacro*{pageref}{}

\makeatletter
\define@key{blx@bib1}{precode}{}
\define@key{blx@biblist1}{precode}{}
\define@key{blx@bib2}{precode}{\blx@key@precode{#1}}
\define@key{blx@biblist2}{precode}{\blx@key@precode{#1}}

\def\blx@key@precode#1{\def\blx@hook@option@precode{#1}}

\define@key{blx@bib1}{postcode}{}
\define@key{blx@biblist1}{postcode}{}
\define@key{blx@bib2}{postcode}{\blx@key@postcode{#1}}
\define@key{blx@biblist2}{postcode}{\blx@key@postcode{#1}}

\def\blx@key@postcode#1{\def\blx@hook@option@postcode{#1}}

\def\blx@bibliography{%
  \blx@langstrings
  \blx@bibheading\blx@theheading\blx@thetitle
  \blx@bibnote\blx@theprenote
  \begingroup
  \blx@bibinit
  \let\@noitemerr\@empty
  \let\blx@noitem\blx@warn@bibempty
  \ifnum\bibinitsep=\z@
    \let\blx@initsep\relax
  \fi
  \ifnum\bibnamesep=\z@
    \let\blx@namesep\relax
  \fi
  \csuse{blx@env@\blx@theenv}%
  \csuse{blx@hook@bibinit}%
  \csuse{blx@hook@bibinit@next}%
  \csuse{blx@hook@option@precode}% <--- this is new
  \let\blx@do\blx@bibitem
  \let\blx@done\blx@endbibliography
  \blx@listloop}

\def\blx@endbibliography{%
  \csuse{blx@hook@option@postcode}% <--- this is new
  \csuse{blx@endenv@\blx@theenv}%
  \blx@noitem
  \endgroup
  \blx@bibnote\blx@thepostnote
  \endgroup}
\makeatother


\begin{document}
\cite{Muller.M:2014a}
\citefilm{Kubrick.S:1964}

\printbibliography[nottype=movie]

\newrefcontext[sorting=title]
\printbibliography[type=movie,precode={\restorebibmacro{pageref}}]
\end{document}
1

You may define a new citation command (\citenbf) with no backref calling \backtrackerref in the precode part (derived from the original \cite command found in fiwi.cbx):

\DeclareCiteCommand{\citenbf}
  {\backtrackerfalse\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

Your modified example:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\usepackage[style=fiwi,backref]{biblatex}
\DeclareCiteCommand{\citenbf}
  {\backtrackerfalse\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@incollection{Muller.M:2014a,
Address = {Baden-Baden},
Author = {Müller, Martin},
Booksubtitle = {Zum Staatsverständnis in den klassischen Utopien},
Booktitle = {Idealstaat oder Gedankenexperiment?},
Editor = {Schölderle, Thomas},
Pages = {287--304},
Publisher = {Nomos},
Title = {Richard Rortys \emph{Contingency, Irony, and Solidarity} (1989)},
Year = {2014}}
@movie{Kubrick.S:1964,
Address = {GB},
Author = {Kubrick, Stanley},
Shorttitle = {Dr. Strangelove},
Subtitle = {Dr. Seltsam oder Wie ich lernte, die Bombe zu lieben},
Title = {Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb},
Year = {1964}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\citenbf{Muller.M:2014a}
\citefilm{Kubrick.S:1964}
\printbibliography[nottype=movie]
\newrefcontext[sorting=title]
\printbibliography[type=movie]
\end{document}

enter image description here

  • Thanks, but this means that I would have to decide when quoting a source wether backref should be enabled. I'd much prefer it if I could do this at a later point. – Simifilm Dec 20 '16 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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