TexLive 使用 bibentry 处理包含 ISBN 和 URL 字段的条目时出现问题

TexLive 使用 bibentry 处理包含 ISBN 和 URL 字段的条目时出现问题

(提前感谢您的反馈!)

我在使用 \bibentry 处理包含 ISBN 或 URL 字段的书目条目时遇到了问题。我的文档在 Win7 x64 上使用 MikTex 时运行良好,但使用 TexLive 2013(来自 Ubuntu 14 存储库)或 TexLive 2015(来自 TexLive 页面)时出现问题。虽然我的主要工作流程使用 MikTex,但我很好奇 TexLive 出现问题的原因以及可能的解决方法。

我已经将问题归结为 \bibentry 的使用以及 bibtex 版本的 TexLive 在 bbl 文件中创建的其他宏。以下是我的 MWE 文件以及 MikTex 和 TexLive 2015 的输出:

mwe.tex:

\documentclass[final]{scrbook}

\usepackage{bibentry}
\nobibliography*        % Tells bibentry to (re)use the bibliographic data from the standard BibTeX setup by \bibliography{} at the end

\begin{document}
This is working fine~\cite{p:thepaper}.

This fails: \bibentry{p:thepaper}.

\bibliographystyle{is-alpha}
\bibliography{mwe}

\end{document}

mwe.bib:

@inproceedings{p:thepaper,
  author = {Me, Myself and Myself, I},
  title = {The Title},
  year = {2015},
  isbn = {123-1-123-12345-1},
  publisher = "The publisher",
  url = {http://dx.doi.org/12.1234/123-1-123-12345-1_23},
  doi = {12.1234/123-1-123-12345-1_23},
  pages = {123--321}
}

输出 TexLive 2015(Ubuntu 14):

*

)) (/usr/local/texlive/2015/texmf-dist/tex/latex/natbib/bibentry.sty)
(./mwe.bbl (/usr/local/texlive/2015/texmf-dist/tex/generic/path/path.sty
This is path.sty, Version 3.05 <7-Apr-2011>
)) (./mwe.aux)
LaTeX Warning: Citation `p:thepaper' on page 1 undefined on input line 7.
LaTeX Warning: Citation `p:thepaper' undefined on input line 9.
! Undefined control sequence.
<argument> ...ublisher, 2015. \newblock \showISBN
                                                  {123-1-123-12345-1}. \newb...
l.9 This fails: \bibentry{p:thepaper}
                                     .
?

*

mwe.bbl(由TexLive 2015制作,失败):

\begin{thebibliography}{MM15}
\ifx \showCODEN  \undefined \def \showCODEN #1{CODEN #1}  \fi
\ifx \showISBN   \undefined \def \showISBN  #1{ISBN #1}   \fi
\ifx \showISSN   \undefined \def \showISSN  #1{ISSN #1}   \fi
\ifx \showLCCN   \undefined \def \showLCCN  #1{LCCN #1}   \fi
\ifx \showPRICE  \undefined \def \showPRICE #1{#1}        \fi
\ifx \showURL    \undefined \def \showURL {URL }          \fi
\ifx \path       \undefined \input path.sty               \fi
\ifx \ifshowURL \undefined
     \newif \ifshowURL
     \showURLtrue
\fi

\bibitem[MM15]{p:thepaper}
Myself Me and I~Myself.
\newblock The title.
    \newblock pages 123--321. The publisher, 2015.
\newblock \showISBN{123-1-123-12345-1}.
\newblock \ifshowURL {\showURL
  \path|http://dx.doi.org/12.1234/123-1-123-12345-1_23|}\fi.

\end{thebibliography}

mwe.bbl (由 MikTex 制作,运行良好):

\begin{thebibliography}{MM15}

\bibitem[MM15]{p:thepaper}
Myself Me and I~Myself.
\newblock The title.
\newblock pages 123--321. The publisher, 2015.
\newblock ISBN 123-1-123-12345-1.

\end{thebibliography}

我尝试在使用 bibentry 包之前在 mwe.tex 中包含一些 bbl 文件的宏,以便在使用之前可以获得它们的定义:

\global\def \showISBN  #1{ISBN #1}
\global\def \showURL {URL }
\input path.sty
\ifx \ifshowURL \undefined
     \newif \ifshowURL
     \showURLtrue
\fi

但是,我不断收到以下错误:

) (/usr/local/texlive/2015/texmf-dist/tex/latex/natbib/bibentry.sty) (./mwe.bbl
)
! Incomplete \ifx; all text was ignored after line 9.
<inserted text>
                \fi
l.12 \nobibliography*
                                % Tells bibentry to (re)use the bibliographic data fr...

? q

非常感谢您的建议!Miguel

PS:关于 Miktex:

bibtex --version
MiKTeX-BibTeX 2.9.5700 (0.99d) (MiKTeX 2.9 64-bit)

在 TexLive 2015 上:

bibtex --version
BibTeX 0.99d (TeX Live 2015)
kpathsea version 6.2.1

答案1

bibentry是其中的一部分natbib,我认为它就是在这种背景下设计的。虽然它可能处理任意书目样式,我怀疑这很大程度上取决于特定的样式。is-alpha.bst因为不是的一部分natbib,你不能指望它与一起工作bibentry

如果你使用natbib兼容的样式,例如 bog-standard alpha,那么一切都正常:

工作成果

\begin{filecontents}{\jobname.bib}
@inproceedings{p:thepaper,
  author = {Me, Myself and Myself, I},
  title = {The Title},
  booktitle = {The Title},
  year = {2015},
  isbn = {123-1-123-12345-1},
  publisher = "The publisher",
  url = {http://dx.doi.org/12.1234/123-1-123-12345-1_23},
  doi = {12.1234/123-1-123-12345-1_23},
  pages = {123--321}
}
\end{filecontents}

\documentclass{article}
\usepackage{natbib}
\usepackage{bibentry}
\nobibliography*        % Tells bibentry to (re)use the bibliographic data from the standard BibTeX setup by \bibliography{} at the end

\begin{document}
This is working fine~\cite{p:thepaper}.

This works fine when you use a \verb|natbib|-compatible style: \bibentry{p:thepaper}.

\bibliographystyle{alpha}
\bibliography{\jobname}

\end{document}

但是,我不确定它为什么能与 MikTeX 兼容,因为最近似乎没有更新任何文件。除非是 LaTeX 内核发生了变化……?

答案2

booktitle={Book Title},使用当前的 MiKTeX 2.9,在我向您的 bib 条目中添加缺失值后,我可以编译您给定的代码,而不会出现错误或警告。

我将您的文档类更改为,以便scrartcl在一页上显示文本和参考书目(如果我使用,结果不会改变scrbook)。

我使用包filecontentsbib文件和tex代码放在一个可编译文件中。如果您命名文件,\jobname则会更改为文件名。mwemwe.tex

我添加了命令\listfile来获取日志文件中使用的软件包和版本的列表。请将此列表与您计算机上的结果进行比较。我猜您正在使用一个或多个过时的版本...

梅威瑟:

\listfiles % creates list of used packages and versions in log file
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@inproceedings{p:thepaper,
  author    = {Me, Myself and Myself, I},
  title     = {The Title},
  booktitle = {The Book Title},
  year      = {2015},
  isbn      = {123-1-123-12345-1},
  publisher = "The publisher",
  url       = {http://dx.doi.org/12.1234/123-1-123-12345-1_23},
  doi       = {12.1234/123-1-123-12345-1_23},
  pages     = {123--321},
}
\end{filecontents*}


\documentclass[final]{scrartcl}%scrbook scrartcl

\usepackage{bibentry}
\nobibliography*        % Tells bibentry to (re)use the bibliographic data from the standard BibTeX setup by \bibliography{} at the end

\begin{document}
This is working fine~\cite{p:thepaper}.

This fails: \bibentry{p:thepaper}.

\bibliographystyle{is-alpha}
\bibliography{\jobname}

\end{document}

使用的软件包和版本列表:

 *File List*
filecontents.sty    2011/10/08 v1.3 Create an external file from within a LaTeX document
scrartcl.cls    2015/07/02 v3.18 KOMA-Script document class (article)
scrkbase.sty    2015/07/02 v3.18 KOMA-Script package (KOMA-Script-dependent basics and keyval usage)
 scrbase.sty    2015/07/02 v3.18 KOMA-Script package (KOMA-Script-independent basics and keyval usage)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
scrlfile.sty    2015/07/02 v3.18 KOMA-Script package (loading files)
tocbasic.sty    2015/07/02 v3.18 KOMA-Script package (handling toc-files)
scrsize11pt.clo    2015/07/02 v3.18 KOMA-Script font size class option (11pt)
typearea.sty    2015/07/02 v3.18 KOMA-Script package (type area)
bibentry.sty    2007/10/30 1.5 (PWD)

结果如下:

在此处输入图片描述

相关内容