编辑。我编辑了我的问题以使其更清楚。
前言。 感谢filecontents
环境,下面的编译pdflatex
生成了两个子文件:
- 书目文件:
subfile.bib
, - 一个完整的
.tex
文件:subfile.tex
,最终可以通过pdflatex
(+biber
等)进行处理,以便获得subfile.pdf
与 提供的参考书目相符的文件subfile.bib
。
请注意,由于standalone
带有其sort
选项的包,该main.tex
文件\input
是完全的 subfile.tex
没有任何问题:它与pdflatex
(+biber
等)的编译很顺利,而且我们还获得了main.pdf
所提供的参考书目subfile.bib
。
% Generates subfile.bib
\begin{filecontents}{subfile.bib}
@book{foo,
title = {Foo},
author = {Bar},
date = {2015-01-01}
}
\end{filecontents}
%
% Generates subfile.tex
\begin{filecontents}{subfile}
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\addbibresource{subfile.bib}
\begin{document}
Look at \autocite{foo}.
\printbibliography
\end{document}
\end{filecontents}
%
% Main file `main.tex`
\documentclass{article}
\usepackage[%
sort
% ,group=false
]{standalone}
\usepackage[backend=biber]{biblatex}
\begin{document}
\input{subfile}
\end{document}
重点是,如果group=false
中被注释掉main.tex
,那么它的pdflatex
编译仍然可以,但是它的biber
编译会失败并出现错误:
INFO - This is Biber 2.1
INFO - Logfile is 'main.blg'
INFO - Reading 'main.bcf'
:2239: parser error : Premature end of data in tag section line 2237
^
:2239: parser error : Premature end of data in tag controlfile line 2
确实,此main.bcf
文件中对应的两个 XML 标签并未关闭。
该standalone
计划规定:
if
group=true
(默认),document
子文件的环境将变为除了添加通常的组之外不执行任何操作的环境。如果设置false
为此环境,则环境将变得透明,这样就不会添加任何组。
你知道为什么group=false
(子文件内容周围没有添加组)会出现这个biber
错误吗?
这是我的文件列表:
*File List*
article.cls 2014/09/29 v1.4h Standard LaTeX document class
size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
standalone.sty 2015/07/15 v1.2 Package to include TeX sub-files with preambl
es
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
xkeyval.sty 2014/12/03 v2.7a package option processing (HA)
xkeyval.tex 2014/05/09 v2.6d key=value parser (HA)
currfile.sty 2013/02/01 v0.7b Provides the file path elements of the current
input file
kvoptions.sty 2011/06/30 v3.11 Key value format for package options (HO)
ltxcmds.sty 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
kvsetkeys.sty 2012/04/25 v1.16 Key value parser (HO)
infwarerr.sty 2010/04/08 v1.3 Providing info/warning/error messages (HO)
etexcmds.sty 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
filehook.sty 2011/10/12 v0.5d Hooks for input files
main.sta
gincltex.sty 2011/09/04 v0.3 Include external LaTeX files like graphics
svn-prov.sty 2010/04/24 v3.1862 Package Date/Version from SVN Keywords
adjustbox.sty 2012/05/21 v1.0 Adjusting TeX boxes (trim, clip, ...)
adjcalc.sty 2012/05/16 v1.1 Provides advanced setlength with multiple back-
ends (calc, etex, pgfmath)
trimclip.sty 2012/05/16 v1.0 Trim and clip general TeX material
graphicx.sty 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2014/10/28 v1.0p Standard LaTeX Graphics (DPC,SPQR)
trig.sty 1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live
pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
collectbox.sty 2012/05/17 v0.4b Collect macro arguments as boxes
tc-pdftex.def 2012/05/13 v1.0 Clipping driver for pdftex
ifoddpage.sty 2011/09/13 v1.0 Conditionals for odd/even page detection
varwidth.sty 2009/03/30 ver 0.92; Variable-width minipages
filemod-expmin.sty 2011/09/19 v1.2 Get and compare file modification times (
expandable; minimal)
biblatex.sty 2015/04/19 v3.0 programmable bibliographies (PK/JW/AB)
biblatex2.sty 2015/04/19 v3.0 programmable bibliographies (biber) (PK/JW/AB)
etoolbox.sty 2015/08/02 v2.2a e-TeX tools for LaTeX (JAW)
logreq.sty 2010/08/04 v1.0 xml request logger
logreq.def 2010/08/04 v1.0 logreq spec v1.0
ifthen.sty 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
url.sty 2013/09/16 ver 3.4 Verb mode for urls, etc.
blx-dm.def
biblatex-dm.cfg
blx-compat.def 2015/04/19 v3.0 biblatex compatibility (PK/JW/AB)
biblatex.def
standard.bbx 2015/04/19 v3.0 biblatex bibliography style (PK/JW/AB)
numeric.bbx 2015/04/19 v3.0 biblatex bibliography style (PK/JW/AB)
numeric.cbx 2015/04/19 v3.0 biblatex citation style (PK/JW/AB)
biblatex.cfg
filecontents.sty 2011/10/08 v1.3 Create an external file from within a LaTeX
document
english.lbx 2015/04/19 v3.0 biblatex localization (PK/JW/AB)
main.sta
supp-pdf.mkii
pdftexcmds.sty 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
epstopdf-base.sty 2010/02/09 v2.5 Base part for package epstopdf
grfext.sty 2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty 2011/04/07 v1.3 Define keys (HO)
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
subfile.tex
***********
答案1
正如你正确指出的那样,你的.bcf
文件缺少一些结束 XML 标签,并且(至少其中一些)这些标签是通过
\AfterEndDocument{%
\blx@auxwrite\blx@bcfout{}{%
\blx@xml@endsection\blx@nl
\csuse{blx@xml@slistsbib}%
\blx@xml@endfile}%
\immediate\closeout\blx@bcfout}
因此,看起来etoolbox
的\AfterEndDocument
钩子并不像这里宣传的那样有效。(尽管一些测试\AfterEndDocument{\typeout{foo}}
进行得相当顺利。)
你必须在加载包之前先加载etoolbox
(该包需要biblatex
并加载该包)standalone
。类似的问题\AfterEndDocument
在软件包不兼容:etoolbox、hyperref 和 bm,独立吗?
所以
\listfiles
% Generates subfile.bib
\begin{filecontents}{subfile.bib}
@book{foo,
title = {Foo},
author = {Bar},
date = {2015-01-01}
}
\end{filecontents}
%
% Generates subfile.tex
\begin{filecontents}{subfile}
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\addbibresource{subfile.bib}
\begin{document}
Look at \autocite{foo}.
\printbibliography
\end{document}
\end{filecontents}
%
% Main file `main.tex`
\documentclass{article}
\usepackage{etoolbox}
\usepackage[%
sort
,group=false
]{standalone}
\usepackage[backend=biber]{biblatex}
\begin{document}
\input{subfile}
\end{document}
正如广告所宣传的那样。