我正在处理一个(非常)大的文档,我希望将我的书目条目定义得尽可能接近我正在处理的文本。因此,我使用“filecontents”包来定义单独的文件,并使用计数器作为后缀。使用 Latex 进行第一次操作后,我只需将条目合并到一个文件中 - 使用 MSDOS copy /b %WORKDIR%\biblio.* .\biblio.bib - 然后调用 biber 并再次执行 LaTeX。以下代码可以正常工作。
\documentclass[]{article}
\usepackage[autostyle]{csquotes}
\usepackage{lipsum}
\usepackage[backend=biber,doi=false,url=true,eprint=true,style=ieee]{biblatex}
\usepackage[]{hyperref}
\hypersetup{colorlinks=true}
\usepackage{filecontents}
\newcounter{BibFileCount}
\addbibresource{biblio.bib}
\begin{document}
\stepcounter{BibFileCount}\begin{filecontents}{biblio.\arabic{BibFileCount}}
@article{kastenholz,
author = {Kastenholz, M. A. and H{\"u}nenberger, Philippe H.},
title = {Computation of methodology\hyphen independent ionic solvation
free energies from molecular simulations},
journaltitle = jchph,
date = 2006,
subtitle = {I. The electrostatic potential in molecular liquids},
volume = 124,
eid = 124106,
doi = {10.1063/1.2172593},
langid = {english},
langidopts = {variant=american},
indextitle = {Computation of ionic solvation free energies},
annotation = {An \texttt{article} entry with an \texttt{eid} and a
\texttt{doi} field. Note that the \textsc{doi} is transformed
into a clickable link if \texttt{hyperref} support has been
enabled},
}
\end{filecontents}
\stepcounter{BibFileCount}\begin{filecontents}{biblio.\arabic{BibFileCount}}
@article{sigfridsson,
author = {Sigfridsson, Emma and Ryde, Ulf},
title = {Comparison of methods for deriving atomic charges from the
electrostatic potential and moments},
journaltitle = {Journal of Computational Chemistry},
date = 1998,
volume = 19,
number = 4,
pages = {377-395},
doi = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
langid = {english},
langidopts = {variant=american},
indextitle = {Methods for deriving atomic charges},
annotation = {An \texttt{article} entry with \texttt{volume},
\texttt{number}, and \texttt{doi} fields. Note that the
\textsc{doi} is transformed into a clickable link if
\texttt{hyperref} support has been enabled},
}
\end{filecontents}
Lorem ipsum dolor sit amet~\supercite{kastenholz}.
At vero eos et accusam et justo duo dolores et ea rebum~\supercite{sigfridsson}.
\printbibliography
\end{document}
但是,尝试创建宏时,我的条目创建失败(创建的文件为空)。我怀疑书目条目在作为宏参数传递之前已被 LaTeX 解释,我不知道如何防止这种情况发生。因此,此代码是错误的:
\newcounter{BibFileCount}
\newcommand{\addbiblioref}[1]{
\stepcounter{BibFileCount}
\begin{filecontents}{biblio.\arabic{BibFileCount}}
#1
\end{filecontents}
}
\addbiblioref{
@book{massa,
author = {Werner Massa},
title = {Crystal structure determination},
date = 2004,
edition = 2,
publisher = {Spinger},
location = {Berlin},
langid = {english},
langidopts = {variant=british},
annotation = {A \texttt{book} entry with an \texttt{edition} field},
}
}
有什么想法可以帮助我吗?提前致谢。
答案1
逐字环境不能作为另一个命令的参数。您可以在fancyvrb
包的帮助下定义一个新的环境写出文件:
\documentclass[]{article}
\usepackage[autostyle]{csquotes}
\usepackage{lipsum}
\usepackage[backend=biber,doi=false,url=true,eprint=true,style=ieee]{biblatex}
\usepackage[]{hyperref}
\hypersetup{colorlinks=true}
\usepackage{fancyvrb}
\newcounter{BibFileCount}
\newenvironment{addbiblioref}
{\stepcounter{BibFileCount}%
\VerbatimEnvironment
\begin{VerbatimOut}{biblio.\theBibFileCount}}
{\end{VerbatimOut}}
\addbibresource{biblio.bib}
\begin{document}
\begin{addbiblioref}
@article{kastenholz,
author = {Kastenholz, M. A. and H{\"u}nenberger, Philippe H.},
title = {Computation of methodology\hyphen independent ionic solvation
free energies from molecular simulations},
journaltitle = jchph,
date = 2006,
subtitle = {I. The electrostatic potential in molecular liquids},
volume = 124,
eid = 124106,
doi = {10.1063/1.2172593},
langid = {english},
langidopts = {variant=american},
indextitle = {Computation of ionic solvation free energies},
annotation = {An \texttt{article} entry with an \texttt{eid} and a
\texttt{doi} field. Note that the \textsc{doi} is transformed
into a clickable link if \texttt{hyperref} support has been
enabled},
}
\end{addbiblioref}
\begin{addbiblioref}
@article{sigfridsson,
author = {Sigfridsson, Emma and Ryde, Ulf},
title = {Comparison of methods for deriving atomic charges from the
electrostatic potential and moments},
journaltitle = {Journal of Computational Chemistry},
date = 1998,
volume = 19,
number = 4,
pages = {377-395},
doi = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
langid = {english},
langidopts = {variant=american},
indextitle = {Methods for deriving atomic charges},
annotation = {An \texttt{article} entry with \texttt{volume},
\texttt{number}, and \texttt{doi} fields. Note that the
\textsc{doi} is transformed into a clickable link if
\texttt{hyperref} support has been enabled},
}
\end{addbiblioref}
Lorem ipsum dolor sit amet~\supercite{kastenholz}.
At vero eos et accusam et justo duo dolores et ea rebum~\supercite{sigfridsson}.
\printbibliography
\end{document}
这是.1
文件,供检查:
@article{kastenholz,
author = {Kastenholz, M. A. and H{\"u}nenberger, Philippe H.},
title = {Computation of methodology\hyphen independent ionic solvation
free energies from molecular simulations},
journaltitle = jchph,
date = 2006,
subtitle = {I. The electrostatic potential in molecular liquids},
volume = 124,
eid = 124106,
doi = {10.1063/1.2172593},
langid = {english},
langidopts = {variant=american},
indextitle = {Computation of ionic solvation free energies},
annotation = {An \texttt{article} entry with an \texttt{eid} and a
\texttt{doi} field. Note that the \textsc{doi} is transformed
into a clickable link if \texttt{hyperref} support has been
enabled},
}
然而,我不认为将书目条目分散在文档中是有帮助的。我确信这非常没有帮助。