3

I'm using the solution by karlkoeller to biblatex: pagebackref reference in the flush right margin and like the result. However, the list of backrefs does not break to a newline which is problematic if an entry is referenced too often with the list of backrefs crossing the page margin.

Is there a way to a) make them break before the page margin and b) move the next bib entry down if necessary. I'm also interested in other visually appealing ways to display backrefs.

MWE

\documentclass{article}
\usepackage{times}
\usepackage{csquotes}
\usepackage{xcolor}
\usepackage[style=numeric-comp,backref=true,backend=biber]{biblatex}
\usepackage{filecontents}
\usepackage{pgffor}

\begin{filecontents}{\jobname.bib}
@book{saad00,
  title = {Iterative Methods for Sparse Linear Systems},
  year = {2000},
  author = {Y. Saad}}
@book{vonNMorg44,
  title = {Theory of Games and Economic Behavior},
  year = {1944},
  author = {J. von Neumann and O. Morgenstern}} 
\end{filecontents}

\addbibresource{\jobname.bib}

% pagereference in the right margin
\renewbibmacro*{pageref}{%
   \iflistundef{pageref}
     {\renewcommand{\finentrypunct}{\addperiod}}
     {\renewcommand{\finentrypunct}{\addspace}%
      \printtext{\addperiod\hfill\rlap{\hskip15pt\colorbox{blue!5}{\scriptsize\printlist[pageref][-\value{listtotal}]{pageref}}}}}}

\begin{document}
\foreach \n in {0,...,20}{text \cite{vonNMorg44} \newpage text \newpage}
\nocite{saad00}
\printbibliography
\end{document}

problem illustration: backrefs ignoring page margin

HGS
  • 31
  • 2

1 Answers1

3

I just answered a similar question on the German goLaTeX forum https://golatex.de/viewtopic.php?f=15&t=23075.

The solution does not only place the back references in a \parbox to make the list breakable, it also uses a different approach to printing in the margin that gives slightly better results (it aligns the margin note with the first and not the last line of the entry).

\documentclass[british]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{xcolor}
\usepackage[style=numeric-comp,backref=true,backend=biber]{biblatex}
\usepackage{pgffor}

\newlength{\marginwritesep} \setlength{\marginwritesep}{0.5em} \newlength{\marginwritewidth} \setlength{\marginwritewidth}{3cm}

% based on egreg's (https://tex.stackexchange.com/users/4427/egreg) % answer to https://tex.stackexchange.com/a/123451/35864 % originally CC BY-SA 3.0, but dual-licensed under LPPL % see https://tex.meta.stackexchange.com/a/3333/35864 \newcommand{\marginwrite}[1]{% \strut\vadjust{% \vbox to 0pt{% \kern-\the\dimexpr\ht\strutbox+\dp\strutbox\relax \hfill\rlap{\kern\marginwritesep #1}% \vss }% }% }

\newcommand*{\simplecolorparbox}[3]{% \colorbox{#1}{\parbox{#2}{#3}}}

\makeatletter \renewbibmacro*{begentry}{% \iflistundef{pageref} {} {\marginwrite{% \simplecolorparbox{blue!5}{\marginwritewidth}{% \scriptsize\raggedright \printlist[pageref][-\value{listtotal}]{pageref}}}% \blx@initunit}} \makeatother

\renewbibmacro*{pageref}{}%

\addbibresource{biblatex-examples.bib}

\begin{document} \foreach \n in {0,...,20}{text \cite{sigfridsson} \newpage text \newpage} \nocite{worman} \printbibliography \end{document}

Bibliography entry with nicely broken page backreferences.

moewe
  • 175,683