我想使用来自此的个人宏来引用 biblatex例子. 但我对此有两个问题。
当我不使用个人宏时
\defbibentrysetlabel
,biber 会给出错误ERROR - Data file 'test-msets.bib' cannot be read in encoding 'utf8'
。我认为这与文件为空有关。当我在嵌入文件中使用此命令时
standalone
,出现错误! Emergency stop.
,我不知道如何解决。
这是一个由 3 个文件组成的示例:
第一个文件是名为preamble.tex
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[style=alphabetic,
mcite=true,
subentry,
maxcitenames=3,
backend=biber
]{biblatex}
\makeatletter
% warning the file called \blxmset@bibfile@name will be
% overwritten without warning
\def\blxmset@bibfile@name{\jobname -msets.bib}
\newwrite\blxmset@bibfile
\immediate\openout\blxmset@bibfile=\blxmset@bibfile@name
\AtEndDocument{%
\closeout\blxmset@bibfile}
\newrobustcmd*{\defbibentrysetlabel}[3]{%
\@bsphack
\begingroup
\immediate\write\blxmset@bibfile{%
@set{#1, entryset = {\unexpanded{#3}}, %
shorthand = {\unexpanded{#2}},}%
}%
\nocite{#1}%
\@esphack}
\addbibresource{\blxmset@bibfile@name}
\makeatother
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Yvon_1935,
title = {La Th\'eorie Statistique Des Fluides et l'\'equation d'\'etat},
series = {Actualit\'es Scientifiques et Industrielles ; {Th\'eories} M\'ecaniques (Hydrodynamique-Acoustique)},
publisher = {Hermann \& cie},
date = {1935},
author = {Yvon, Jacques},
lccn = {37018772}
}
@article{Born_1946,
title = {A General Kinetic Theory of Liquids {I}. {The} Molecular Distribution Functions},
volume = {188},
issn = {2053-9169},
doi = {10.1098/rspa.1946.0093},
number = {1012},
journaltitle = {Proceedings of the Royal Society of London. Series A. Mathematical and Physical Sciences},
date = {1946-12-31},
pages = {10-18},
author = {Born, Max and Green, Herbert Sydney},
}
@article{Kirkwood_1946,
title = {The Statistical Mechanical Theory of Transport Processes {I}. {General} Theory},
volume = {14},
url = {http://aip.scitation.org/doi/10.1063/1.1724117},
doi = {10.1063/1.1724117},
number = {3},
journaltitle = {The Journal of Chemical Physics},
urldate = {2019-01-16},
date = {1946-03},
pages = {180-201},
author = {Kirkwood, John Gamble},
}
@article{Bogolioubov_1945,
title = {Kinetic Equations},
volume = {10},
number = {3},
journaltitle = {Journal of Physics USSR},
date = {1945},
pages = {265-274},
author = {Bogolioubov, Nikola\"i Nikola\"ievitch}
}
@article{Boncella_1984,
author = {Boncella, James M. and Andersen, Richard A.},
journal = {Inorg. Chem.},
pages = {432--437},
volume = {23},
year = {1984},
}
\end{filecontents}
\addbibresource[datatype=bibtex]{\jobname.bib}
然后嵌入的文件test_include.tex
:
\documentclass{article}
\input{preamble.tex}
\begin{document}
A first citation~\cite{Boncella_1984}.
And another that I want to cite as a set BBGKY45 \defbibentrysetlabel{setBBGKY}{BBGKY45}{Yvon_1935,Bogolioubov_1945,Born_1946,Kirkwood_1946}\cite{setBBGKY}.
\printbibliography
\end{document}
主要内容test_main.tex
:
\documentclass{article}
\input{preamble.tex}
\usepackage{standalone}
\begin{document}
test3 \cite{Boncella_1984}
\input{./test_include.tex}
\end{document}
在这个例子中,我可以test_include.tex
毫无问题地进行编译。但是当我尝试test_main.tex
按此方法编译时,第一次编译时会遇到第二个问题。如果我注释掉该行\input{./test_include.tex}
,则在 biber 编译时会遇到第一个问题。
答案1
我回答的第二部分使用 biblatex mcite 命令时使用所有姓名首字母包含一个错误。
的定义\defbibentrysetlabel
包含\begingroup
但没有匹配的\endgroup
。\begingroup
可以删除。定义应为
\newrobustcmd*{\defbibentrysetlabel}[3]{%
\@bsphack
\immediate\write\blxmset@bibfile{%
@set{#1, entryset = {\unexpanded{#3}}, %
shorthand = {\unexpanded{#2}},}%
}%
\nocite{#1}%
\@esphack}
此外,Biber 不喜欢.bib
没有条目的空文件,因此-blx.bib
我们可以简单地添加一个虚假@comment
条目
\immediate\write\blxmset@bibfile{%
@comment{auxiliary file for \string\defbibentrysetlabel}^^J%
@comment{This file may safely be deleted.
It will be recreated as required.}}
因此,完整实施\makeatletter...\makeatother
应为
\makeatletter
% warning the file called \blxmset@bibfile@name will be
% overwritten without warning
\def\blxmset@bibfile@name{\jobname -msets.bib}
\newwrite\blxmset@bibfile
\immediate\openout\blxmset@bibfile=\blxmset@bibfile@name
\immediate\write\blxmset@bibfile{%
@comment{auxiliary file for \string\defbibentrysetlabel}^^J%
@comment{This file may safely be deleted.
It will be recreated as required.}}
\AtEndDocument{%
\closeout\blxmset@bibfile}
\newrobustcmd*{\defbibentrysetlabel}[3]{%
\@bsphack
\immediate\write\blxmset@bibfile{%
@set{#1, entryset = {\unexpanded{#3}}, %
shorthand = {\unexpanded{#2}},}%
}%
\nocite{#1}%
\@esphack}
\addbibresource{\blxmset@bibfile@name}
\makeatother
我对另一个答案进行了相应的编辑。