1

As a follow up to this question and moewe's answer, I am trying to figure out why the citation labels in the annotated bibliography are not printed correctly. Here's the MWE:

\documentclass{amsart}
\usepackage{blindtext}
\usepackage[sorting=ynt, backend=biber, style=numeric-comp]{biblatex}
\usepackage{hyperref}

\assignrefcontextentries*[sorting=nyt, labelprefix=A]{*}

\newtoggle{showannotation}
\toggletrue{showannotation}

\renewbibmacro*{finentry}{%
  \iftoggle{showannotation}
    {\setunit{\par}%
     \printfield{annotation}}
    {}%
  \finentry}

\setlength{\bibitemsep}{.5\baselineskip}
\setlength{\bibparsep}{.5\bibitemsep}

\newlength{\bibparindent}
\setlength{\bibparindent}{0pt}

\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{%
        \printfield{labelprefix}%
        \printfield{labelnumber}}}
     {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \setlength{\listparindent}{\bibparindent}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article {ref1,
    AUTHOR = {Chebyshev, P.},
    TITLE = {{Lettre de M. le professeur Tchebychev a M. Fuss, sur un nouveau th{e}oreme relatif aux nombres premiers contenus dans la formes $4n+1$ et $4n+3$.}},
    FJOURNAL = {Bull. de la Classe phys. math. de l'Acad. Imp. des Sciences St. Petersburg},
    VOLUME = {11},
    YEAR = {1853},
    LANGUAGE = {french},
    annotation = {Chebyshev's paper which was the starting point of the subject.},
}
@article{ref2,
    AUTHOR = {Phragmen, P.},
    TITLE = {{Sur le logarithme integral et la fonction $f(x)$ de Riemann}},
    YEAR  = {1891},
    FJOURNAL = {\"{O}fversigt af Kongl. Vetenskaps--Akademiens F\"{o}handlingar.},
    LANGUAGE = {French},
    VOLUME = {48},
    annotation = {\blindtext \par This article cites~\cite{ref4, ref5}.},
}
@article{ref3,
    AUTHOR = {Landau, E.},
    TITLE = {{U}ber einen {S}atz von {T}schebyschef},
    JOURNAL = {Math. Ann.},
    FJOURNAL = {Mathematische Annalen},
    VOLUME = {61},
    YEAR = {1906},
    NUMBER = {4},
}
@article{ref4,
    author={Littlewood, J. E. },
    title={{Sur la distribution des nombres premiers}},
    year={1914},
    volume={158},
    journal={Comptes Rendus de l'Acad. Sci. Paris},
    language={French},
    annotation = {This article cites~\cite{ref4, ref5}.}
}
@article{ref5,
    author={Hardy, G. H. and Littlewood, J. E. },
    title={{Contributions to the theory of the Riemann zeta-function and the theory of the distribution of primes}},
    year={1916},
    journal={Acta Math.},
    volume={41},
    number={1},
    annotation = {This article cites~\cite{ref1, ref4, ref3}.},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\section{Chronological bibliography}
\printbibliography[heading=none]

\section{Alphabetic bibliography}
\togglefalse{showannotation}
\newrefcontext[sorting=nyt, labelprefix=A] 
\printbibliography[heading=none]
\end{document}

Now if I want to see [4, 5] instead of [A4, A5] (get rid of the A), so as moewe mentioned, the natural way to do that would be to remove labelprefix=A in assignrefcontextentries. However, when I do that, the reference labels are not printed correctly (my own labels are printed: [ref4, ref5]). I've attached a screenshot. I do not understand why having a label prefix would confuse biblatex from printing the cite labels.

enter image description here

2

\assignrefcontextentries[<refcontext>]{<entrykey>} can only go to an existing refcontext for <entrykey>. A refcontext exists for an entry if the entry is printed in a bibliography in that refcontext.

Since you issue \assignrefcontextentries*[<refcontext>]{*}, the refcontext must be valid for all entries.

The following simplified example shows what is going on

\documentclass{article}
\usepackage{blindtext}
\usepackage[backend=biber, style=numeric-comp, sorting=ynt, defernumbers]{biblatex}

\assignrefcontextentries*[sorting=nyt, labelprefix=A]{*}

\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson,geer,nussbaum}

\printbibliography[title={\texttt{sorting=ynt}}]

\newrefcontext[sorting=nyt, labelprefix=A] 
\printbibliography[title={\texttt{sorting=nyt, labelprefix=A}}]
\end{document}

compiles fine and produces

citations from last context with "A"s

Similarly

\documentclass{article}
\usepackage{blindtext}
\usepackage[backend=biber, style=numeric-comp, sorting=ynt, defernumbers]{biblatex}

\assignrefcontextentries*[sorting=ynt]{*}

\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson,geer,nussbaum}

\printbibliography[title={\texttt{sorting=ynt}}]

\newrefcontext[sorting=nyt, labelprefix=A] 
\printbibliography[title={\texttt{sorting=nyt, labelprefix=A}}]
\end{document}

works and produces

citations from the first refcontext without "A"

These examples come out as desired because in both cases the refcontexts used in \assignrefcontextentries exists for all entries.

If we were to pick a non-existing refcontext (sorting=nyt without a labelprefix) we'd end up with

\documentclass{article}
\usepackage{blindtext}
\usepackage[backend=biber, style=numeric-comp, sorting=ynt, defernumbers]{biblatex}

\assignrefcontextentries*[sorting=nyt]{*}

\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson,geer,nussbaum}

\printbibliography[title={\texttt{sorting=ynt}}]

\newrefcontext[sorting=nyt, labelprefix=A] 
\printbibliography[title={\texttt{sorting=nyt, labelprefix=A}}]
\end{document}

Citations not found


For your example that means that you need

\assignrefcontextentries*[sorting=ynt]{*}

instead of

\assignrefcontextentries*[sorting=nyt, labelprefix=A]{*}

Not only do you have to remove the labelprefix, you also need to change the sorting. The reason for that is as in the simplified examples above that the refcontext sorting=nyt alone does not exist.

\documentclass{amsart}
\usepackage{blindtext}
\usepackage[backend=biber, style=numeric-comp, sorting=ynt, defernumbers]{biblatex}
\usepackage{hyperref}

\assignrefcontextentries*[sorting=ynt]{*}

\newtoggle{showannotation}
\toggletrue{showannotation}

\renewbibmacro*{finentry}{%
  \iftoggle{showannotation}
    {\setunit{\par}%
     \printfield{annotation}}
    {}%
  \finentry}

\setlength{\bibitemsep}{.5\baselineskip}
\setlength{\bibparsep}{.5\bibitemsep}

\newlength{\bibparindent}
\setlength{\bibparindent}{0pt}

\defbibenvironment{bibliography}
  {\list
     {\printtext[labelnumberwidth]{%
        \printfield{labelprefix}%
        \printfield{labelnumber}}}
     {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \setlength{\listparindent}{\bibparindent}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article {ref1,
    AUTHOR = {Chebyshev, P.},
    TITLE = {{Lettre de M. le professeur Tchebychev a M. Fuss, sur un nouveau th{e}oreme relatif aux nombres premiers contenus dans la formes $4n+1$ et $4n+3$.}},
    FJOURNAL = {Bull. de la Classe phys. math. de l'Acad. Imp. des Sciences St. Petersburg},
    VOLUME = {11},
    YEAR = {1853},
    LANGUAGE = {french},
    annotation = {Chebyshev's paper which was the starting point of the subject.},
}
@article{ref2,
    AUTHOR = {Phragmen, P.},
    TITLE = {{Sur le logarithme integral et la fonction $f(x)$ de Riemann}},
    YEAR  = {1891},
    FJOURNAL = {\"{O}fversigt af Kongl. Vetenskaps--Akademiens F\"{o}handlingar.},
    LANGUAGE = {French},
    VOLUME = {48},
    annotation = {\blindtext \par This article cites~\cite{ref4, ref5}.},
}
@article{ref3,
    AUTHOR = {Landau, E.},
    TITLE = {{U}ber einen {S}atz von {T}schebyschef},
    JOURNAL = {Math. Ann.},
    FJOURNAL = {Mathematische Annalen},
    VOLUME = {61},
    YEAR = {1906},
    NUMBER = {4},
}
@article{ref4,
    author={Littlewood, J. E. },
    title={{Sur la distribution des nombres premiers}},
    year={1914},
    volume={158},
    journal={Comptes Rendus de l'Acad. Sci. Paris},
    language={French},
    annotation = {This article cites~\cite{ref4, ref5}.}
}
@article{ref5,
    author={Hardy, G. H. and Littlewood, J. E. },
    title={{Contributions to the theory of the Riemann zeta-function and the theory of the distribution of primes}},
    year={1916},
    journal={Acta Math.},
    volume={41},
    number={1},
    annotation = {This article cites~\cite{ref1, ref4, ref3}.},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\section{Chronological bibliography}
\printbibliography[heading=none]

\section{Alphabetic bibliography}
\togglefalse{showannotation}
\newrefcontext[sorting=nyt, labelprefix=A] 
\printbibliography[heading=none]
\end{document}

Bibliography with citations to the <code>ynt</code> refcontext

  • Excellent! I checked and it works, thank you. – Amir Hossein Jul 20 at 16:26

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.