BibTeX url 条目中的对齐制表符 & 位置错误

BibTeX url 条目中的对齐制表符 & 位置错误

我有一个主文档,我正在使用 natbib 包来处理我的 bibtex 数据库。这是我的文档底部,显示了参考书目代码

...
\backmatter
\nocite{*}
\bibliographystyle{plainnat}
\bibliography{mybiblifile}
\end{document}

这是我的代码的底部,看起来很正常。当我在运行几次 BibTeX 后排版所有内容时,我收到此错误消息:

对齐制表符 & 位置错误。您把对齐制表符 '&' 放错了位置。如果您想要对齐某些内容,则必须将其写入对齐环境中,例如 \begin{align} … \end{align}、\begin{tabular} … \end{tabular} 等。如果您想在文本中写入与号 '&',则必须改为写入 \&。

现在我正在打开参考书目文件mybiblifile.bib,其中一条条目引起了我的注意。

@INPROCEEDINGS{frenkel_fine_2013,
title = {Fine temperature measurement and fabrication of on-chip whispering-gallery mode micro-sensors},
url = {http://proxy.library.nyu.edu/login?url=http://search.ebscohost.com/login.aspx?direct=true&db=edselc&AN=edselc.2-52.0-84901804547\&site=eds-live},
doi = {10.1115/MNHMT2013-22003},
booktitle = {{ASME} 2013 4th {International} {Conference} on {Micro}/{Nanoscale} {Heat} and {Mass} {Transfer}, {MNHMT} 2013},
publisher = {American Society of Mechanical Engineers (ASME)},
author = {Frenkel, M. and Avellan, M. and Guo, Z.},
year = {2013},
note = {Conference Proceedings}
}

我意识到是&Bibtex 的 URL 条目中的字符导致了问题。当我从 URL 条目中删除这些字符时,排版工作正常,不再出现错误消息。

我们该如何处理这个问题?

答案1

您没有向我们展示完整的 MWE,没有展示您使用的 documentclass 和使用的包。下次请展示完整的 MWE,而不仅仅是代码片段...

看来您错误地调用了包hyperref(该包url在内部调用)或者如果您不使用,hyperref您应该调用包urlxurl

请参阅以下 MWE(包filecontents仅用于将 bib 文件和 tex 代码一起放在 MWE 中):

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@INPROCEEDINGS{frenkel_fine_2013,
  title = {Fine temperature measurement and fabrication of on-chip whispering-gallery mode micro-sensors},
  url = {http://proxy.library.nyu.edu/login?url=http://search.ebscohost.com/login.aspx?direct=true&db=edselc&AN=edselc.2-52.0-84901804547\&site=eds-live},
  doi = {10.1115/MNHMT2013-22003},
  booktitle = {{ASME} 2013 4th {International} {Conference} on {Micro}/{Nanoscale} {Heat} and {Mass} {Transfer}, {MNHMT} 2013},
  publisher = {American Society of Mechanical Engineers (ASME)},
  author = {Frenkel, M. and Avellan, M. and Guo, Z.},
  year = {2013},
  note = {Conference Proceedings}
}
\end{filecontents*}


\documentclass[10pt,a4paper]{article}

\usepackage{natbib}
%\usepackage{xurl}
\usepackage{hyperref}


\begin{document}

\nocite{*} % to test all bib entrys
\bibliographystyle{plainnat}
\bibliography{\jobname}

\end{document}

并且其结果没有错误消息:

在此处输入图片描述

如果你不喜欢一行末尾的空格,你可以取消注释行

\usepackage{xurl}

在我给出的MWE中。

答案2

我找到了一个非常简洁且有用的答案这里

简而言之,在序言中插入以下一行:

\usepackage[hyphens]{url}

相关内容