0

The source below, along with the biblatex.cfg shown, produces this bibliography that includes backrefs:

actual

Even without any backrefs, each item in the printed bibliography ends with a period.

How can do the following...

  • move the final period so as to go before the backref?
  • insert a period after each backref's closing parenthesis?
  • change each backref's parentheses to square brackets?

... so that the bibliography will look like this:

desired bibliography backrefs

The source:

% File backref.tex
\begin{filecontents}{testbib.bib}
@article{article,
    author = {Author, An},
    title = {An article},
    journal = {Articles},
    volume = {1}, pages = {1--2}, year = {2021},
}
@book{book,
    author = {Writer, Some},
    title = {A Book},
    publisher = {Publisher}, address = {London},
    year = {2021},
}
\end{filecontents}

\begin{filecontents}{backref.lbx} \ProvidesFile{backref.lbx} % Added after original MWE post... % ... included in actual book-length doc: \InheritBibliographyExtras{english} \DeclareBibliographyExtras{% \protected\def\mkbibordinal#1{% \begingroup% @tempcnta0#1\relax\number@tempcnta%% \endgroup}% \protected\def\mkbibmascord{\mkbibordinal}% \protected\def\mkbibfemord{\mkbibordinal}% } \DeclareBibliographyStrings{% inherit = {english}, urlseen = {{accessed}{accessed}}, } \end{filecontents}

\documentclass{article}

\RequirePackage[citestyle=numeric,backref=true]{biblatex} \RequireBibliographyStyle{standard} \RequireBibliographyStyle{numeric} \DefineBibliographyStrings{english}{ backrefpage = {Cited on page}, backrefpages = {Cited on pages}, } \addbibresource{testbib.bib}

\begin{document}

In \textcite{article} and \textcite{book}\dots

\printbibliography

\end{document}

The biblatex config file [corrected]:

% BIBLATEX.CFG - mimic amsplain
\ProvidesFile{biblatex.cfg}

\DeclareNameAlias{sortname}{family-given}

% Punctuation & delimiter mods: \DeclareLanguageMapping{english}{backref} % external file! \renewcommand*{\newunitpunct}{\addcomma\space} \renewcommand{\subtitlepunct}{\addcolon\addspace} \renewbibmacro{in:}{% \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}

% Field mods: \DeclareFieldFormat [article] {title}{\mkbibemph{#1}}% no quote marks \DeclareFieldFormat{journaltitle}{#1} % \DeclareFieldFormat [article] {volume}{\mkbibbold{#1}}
%
\DeclareFieldFormat{pages}{#1}% no prefix for the pages field

% Book mods: \renewbibmacro{publisher+location+date}{% \printlist{publisher}% \setunit{\addcomma\space}% \printlist{location}% \setunit*{\addcomma\space}% \usebibmacro{date}% \newunit}

% Article mods: \DeclareFieldFormat[article,periodical]{number}{\bibstring{number}~#1}% number of a journal

\renewbibmacro{journal+issuetitle}{% \usebibmacro{journal}% \setunit{\addspace}% \iffieldundef{series} {} {\newunit \printfield{series}% \setunit{\addspace}}% \printfield{volume}% \setunit{\addspace}% \usebibmacro{issue+date}% \setunit{\addcomma\space}% \printfield{number}% \setunit{\addcolon\space}% \usebibmacro{issue}% \setunit{\addcomma\space}% \printfield{eid} \newunit}

murray
  • 7,944
  • Those things might just be the remnants of more complex code in a slightly bigger document, but in this example the .lbx file does nothing (and I would recommend you choose a name that also reflects the language - english - it is based on), because it is not selected anywhere, much less so because you actually redefine the language strings with the preamble commands. ... – moewe Jul 31 '21 at 05:55
  • ... In a document preamble it is extremely unusual (and generally not recommended) to load styles with \RequireBibliographyStyle. In this specific setup these lines won't do any harm, but the 'correct' way to load a numeric bib style, is to drop the \RequireBibliographyStyle lines and replace citestyle=numeric, with style=numeric, (which will set both bibstyle and citestyle to numeric). Of course if this is part of a custom .bbx file, things are different. – moewe Jul 31 '21 at 05:56
  • With that biblatex.cfg backref.lbx is used after all. But in its current form it is basically useless and crucially it does not contain the actual string redefinitions you apply to backrefpage and backrefpages. – moewe Jul 31 '21 at 16:22

2 Answers2

4

My attempt below was inspired by biblatex: move backrefpages to after the period.

enter image description here

% File backref.tex
\begin{filecontents}{testbib.bib}
@article{article,
    author = {Author, An},
    title = {An article},
    journal = {Articles},
    volume = {1}, pages = {1--2}, year = {2021},
}
@book{book,
    author = {Writer, Some},
    title = {A Book},
    publisher = {Publisher}, address = {London},
    year = {2021},
}
\end{filecontents}

\begin{filecontents}{backref.lbx} \ProvidesFile{backref.lbx} \InheritBibliographyExtras{english} \end{filecontents}

\documentclass{article}

\RequirePackage[citestyle=numeric,backref=true]{biblatex} \RequireBibliographyStyle{standard} \RequireBibliographyStyle{numeric} \DefineBibliographyStrings{english}{ backrefpage = {Cited on page}, backrefpages = {Cited on pages}, } \renewbibmacro{finentry}{\iflistundef{pageref}{}{\renewcommand{\finentrypunct}{}}\finentry} \renewbibmacro{pageref}{% \iflistundef{pageref} {} {\setunit{\adddot\addspace}\printtext{% \ifnumgreater{\value{pageref}}{1} {[\bibstring{backrefpages}\ppspace} {[\bibstring{backrefpage}\ppspace}% \printlist[pageref][-\value{listtotal}]{pageref}\adddot]}}}

\addbibresource{testbib.bib} \begin{document}

In \textcite{article}% and \textcite{book}\dots \newpage In \textcite{article} and \textcite{book}\dots

\printbibliography

\end{document}

citsahcots
  • 7,992
  • 1
    Does not work if an item is cited on more than one page. E.g., if I append to the document body \newpage In \textcite{article} also \dots, then the first bibliography item now ends with: "(2021), 1-2. [Cited on pages.] Cited on page 1, 2." – murray Jul 30 '21 at 22:55
  • @murray, my bad. It's fixed. – citsahcots Jul 31 '21 at 16:06
4

The punctuation directly before the backref is controlled by \bibpagerefpunct, which we can redefine to print the \finentrypunct (plus a space). Then we just need to make sure that after the backref is printed, no further \finentrypunct is inserted, so we reset its definition in the pageref bibmacro. We also change the brackets via the field format used in pageref. (The original definition of that macro can be found in biblatex.def, ll. 2934-2941 in v3.16.)

\documentclass{article}

\RequirePackage[style=numeric,backref=true]{biblatex}

\DefineBibliographyStrings{english}{ backrefpage = {cited on page}, backrefpages = {cited on pages}, }

\renewcommand*{\bibpagerefpunct}{% \finentrypunct\space}

\DeclareFieldFormat{bracketswithperiod}{\mkbibbrackets{#1\addperiod}}

\renewbibmacro{pageref}{% \iflistundef{pageref} {} {\printtext[bracketswithperiod]{% \ifnumgreater{\value{pageref}}{1} {\bibstring{backrefpages}\ppspace} {\bibstring{backrefpage}\ppspace}% \printlist[pageref][-\value{listtotal}]{pageref}}% \renewcommand{\finentrypunct}{}}}

\addbibresource{biblatex-examples.bib}

\begin{document} In \textcite{sigfridsson} and \textcite{worman}\dots

\clearpage

In \textcite{sigfridsson} and \textcite{nussbaum}\dots

\clearpage

In \textcite{sigfridsson} and \textcite{geer,nussbaum}\dots

\printbibliography \end{document}

Emma Sigfridsson and Ulf Ryde. “Comparison of methods for deriving atomic charges from the electrostatic potential and moments”. In: Journal of Computational Chemistry 19.4 (1998), pp. 377–395. doi: 10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P. [Cited on pages 1–3.]

moewe
  • 175,683
  • With the bibliography format used in my MWE -- modified numeric and the indicated biblatex.cfg (see my corrected post) -- this proposed solution fails to insert a period at the end of the entry (before the backref addition). – murray Jul 31 '21 at 15:46
  • @murray Neither adding the code from your biblatex config file to my MWE directly nor externalising it to biblatex.cfg stopped the period from showing up before the backref. There must be some other code (that you haven't shown) that stops it from doing that. – moewe Jul 31 '21 at 16:20
  • Looking at the biblatex.cfg I see no code that looks as though it should stop my code from working. The only unknown is backref.lbx, if your actual file contains more than the stub shown in the question. – moewe Jul 31 '21 at 16:23
  • Please see my updated post which now includes the entirety of my actual backref.lbx. (Sorry for trying to strip things down to what I thought were the only essentials to concoct the MWE.) – murray Jul 31 '21 at 17:04
  • @murray Mhh, that's not it, either. I still get the period before the backref even with the new .lbx file. Can you please check that my MWE exactly as posted works for you. Can you then check if it works together with your biblatex.cfg. When exactly do things fall apart? – moewe Jul 31 '21 at 17:19
  • Aha: I had put your new bib commands into the .lbx, which failed to put the period at the end of the part of the entry preceding the "[Cited...]" bacref stuff. However, when I moved those commands into my .tex source file, the period appeared where wanted. I don't understand why it makes a difference as to where the definitions are placed; must have something to do with when the .lbx is read and used? – murray Jul 31 '21 at 20:07
  • @murray The .lbx file is only read when the language is selected and it is read in a group, which means that basically all the definitions that are integral to this answer (which are local) are simply discarded. The .lbx should really only contain \DeclareBibliographyExtras and \DeclareBibliographyStrings (or the respective inheritance declarations): Style modifications should not be contained in the .lbx file, they belong into the preamble, a .bbx/.cbx file or biblatex.cfg. – moewe Jul 31 '21 at 20:46