每当我的参考书目文件中的 URL 包含破折号/连字符时,我都会收到以下类型的错误:
LaTeX 警告:第 1 页的引用“wright2006”在输入行 29 未定义。
(./Untitled.bbl ./Untitled.bbl:29: 缺少插入 $。
$ l.29 ...l{https://doi.org/10.1007/0-387-27925-3_2}
我认为如果我删除 URL 字段,就不会出现问题。问题是我有一个bib
包含 300 多个将被引用的条目的大文件。它们中的大多数都包含带有破折号/连字符的 URL 字段。我测试了不包含破折号/连字符的 URL 字段的引用,它们工作正常。我怎样才能做到这一点,而不必浏览整个文件并删除 300 多个 URL 字段?
以下是 MWE:
\documentclass[conference]{IEEEtran}
\usepackage{filecontents,lipsum}
\usepackage[noadjust]{cite}
\begin{filecontents*}{references.bib}
@inbook{wright2006,
Address = {New York, NY},
Author = {Wright, Kenneth W.},
Booktitle = {Handbook of Pediatric Strabismus and Amblyopia},
Date-Added = {2017-09-11 00:07:41 +0000},
Date-Modified = {2017-09-11 00:08:45 +0000},
Doi = {10.1007/0-387-27925-3_2},
Editor = {Wright, Kenneth W. and Spiegel, Peter H. and Thompson, Lisa S.},
Isbn = {978-0-387-27925-1},
Keywords = {Anatomy;Biology;anatomical data;physiology;Eyes;eye movements;biological data},
Pages = {24--69},
Publisher = {Springer New York},
Title = {Anatomy and Physiology of Eye Movements},
Url = {https://doi.org/10.1007/0-387-27925-3_2},
Year = {2006},
}
\end{filecontents*}
\title{This document}
\author{This author}
\begin{document}
\maketitle
I have cited this document \cite{wright2006}
\bibliographystyle{IEEEtran}
\bibliography{references}
\end{document}
答案1
与您在帖子标题中写的内容相反,给您带来麻烦的不是url
和doi
字段中的连字符。而是下划线字符:_
。您需要在序言中加载url
包,最好使用选项hyphens
。这样,TeX 和 BibTeX 就不会尝试将其解释_
为 url 或 doi 字符串中下标材料的发起者。
另一个问题:使用@inbook
手头条目的条目类型是错误的。请使用@incollection
。
最后,书目样式的名称是IEEEtran
,而不是ieeetran
。
完整的 MWE (最小工作示例):
\RequirePackage{filecontents}
\begin{filecontents*}{references.bib}
@incollection{wright2006,
Author = {Wright, Kenneth W.},
Title = {Anatomy and Physiology of Eye Movements},
Editor = {Wright, Kenneth W. and Spiegel, Peter H. and Thompson, Lisa S.},
Booktitle= {Handbook of Pediatric Strabismus and Amblyopia},
Pages = {24-69},
Address = {New York, NY},
Publisher= {Springer},
url = {https://doi.org/10.1007/0-387-27925-3_2},
Year = {2006},
Date-Added = {2017-09-11 00:07:41 +0000},
Date-Modified = {2017-09-11 00:08:45 +0000},
Doi = {10.1007/0-387-27925-3_2},
Isbn = {978-0-387-27925-1},
Keywords = {Anatomy;Biology;anatomical data;physiology;Eyes;eye movements;biological data},
}
\end{filecontents*}
\documentclass[conference]{IEEEtran}
\usepackage[noadjust]{cite}
\usepackage[hyphens]{url} % <--- new
\begin{document}
\noindent
\cite{wright2006}
\bibliographystyle{IEEEtran}
\bibliography{references}
\end{document}