![带注释的参考书目:两个参考书目,标签打印不正确](https://linux22.com/image/398953/%E5%B8%A6%E6%B3%A8%E9%87%8A%E7%9A%84%E5%8F%82%E8%80%83%E4%B9%A6%E7%9B%AE%EF%BC%9A%E4%B8%A4%E4%B8%AA%E5%8F%82%E8%80%83%E4%B9%A6%E7%9B%AE%EF%BC%8C%E6%A0%87%E7%AD%BE%E6%89%93%E5%8D%B0%E4%B8%8D%E6%AD%A3%E7%A1%AE.png)
作为后续行动这个问题和 moewe 的回答,我试图弄清楚为什么带注释的参考书目中的引用标签打印不正确。这是 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}
现在,如果我想看到[4, 5]
而不是[A4, A5]
(摆脱 A),那么 moewe提及,最自然的做法是删除labelprefix=A
。assignrefcontextentries
但是,当我这样做时,参考标签无法正确打印(我自己的标签已打印:[ref4, ref5]
)。我附上了一张截图。我不明白为什么标签前缀会让 biblatex 无法打印引用标签。
答案1
\assignrefcontextentries[<refcontext>]{<entrykey>}
只能去现存的的引用上下文<entrykey>
。如果某条目打印在该引用上下文中的参考书目中,则该条目存在引用上下文。
由于您发出了\assignrefcontextentries*[<refcontext>]{*}
,因此 refcontext 必须对所有条目有效。
以下简化的示例显示了正在发生的事情
\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}
编译成功并生成
相似地
\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}
工作和生产
这些示例符合预期,因为在两种情况下,所使用的 refcontexts 都\assignrefcontextentries
存在于所有条目中。
如果我们选择一个不存在的 refcontext(sorting=nyt
没有labelprefix
),我们最终会得到
\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}
对于你的例子,这意味着你需要
\assignrefcontextentries*[sorting=ynt]{*}
代替
\assignrefcontextentries*[sorting=nyt, labelprefix=A]{*}
您不仅需要删除labelprefix
,还需要更改排序。这样做的原因与上面的简化示例一样,refcontextsorting=nyt
本身并不存在。
\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}