How add biblatex backref after period at end of each item in bibliography

biblatex

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}

Best Answer

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.]

Related Question