在我的一些引文中,url 中有一个 % 符号,这在使用环境时会出现问题bibentry
(段落在 \BR@c@bibitem 完成之前结束)。我该如何处理 % 符号?如果 url 中的参考文献不包含 %,则一切正常。而且,不使用 %bibentry
也不会出现问题。使用不同的书目样式(如 unsrt)时,% 符号也不会出现问题,因为 unsrt 不使用 url 信息(我不想这样做)。(可以在以下位置找到书目样式 statto这里,使用 时也会出现同样的问题plainnat
)。\begin{NoHyper}\bibentry{goossens93}\end{NoHyper}
最好不要使用 来超链接到网站,但我不知道这是否可行。
\begin{filecontents}{mytestbib.bib}
@book{goossens93,
author = "Frank Mittelbach and Michel Goossens and Johannes Braams and David Carlisle and Chris Rowley",
title = "The {LaTeX} Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@BOOK{Kymissis__2009,
title = {Organic Field Effect Transistors - Theory, Fabrication and Characterization},
publisher = {Springer},
year = {2009},
author = {Kymissis, Ioannis},
abstract = {Organic Field Effect Transistors discusses the fundamental mechanisms
that apply to {OFETs} fabrication, operation, and characterization.
This unique book presents the state-of-the-art in organic field effect
transistors ({OFETs)} with ...},
isbn = {9780387921341},
keywords = {Circuits and Systems, Fabrication and Characterization, Organic Chemistry,
Organic Field Effect Transistors - Theory, Technology \& Engineering
/ Engineering (General)},
language = {English},
shorttitle = {Organic Field Effect Transistors},
timestamp = {2013.10.07},
url = {http://www.springer.com/engineering/circuits+%26+systems/book/978-0-387-92133-4}
}
\end{filecontents}
\documentclass{article}
\usepackage[pdftex]{hyperref}
\usepackage{filecontents}
\usepackage{natbib}
\usepackage{bibentry}
\nobibliography*
\begin{document}
A full in-text cite of
\begin{NoHyper}\bibentry{goossens93}\end{NoHyper}.
A regular citation of \cite{goossens93}.
Problematic cite \cite{Kymissis__2009}
\bibliographystyle{statto}
\bibliography{mytestbib}
\end{document}
答案1
这似乎有效:对宏进行修补以在抓取其参数之前\BR@c@bibitem
更改类别代码。%
\begin{filecontents}{mytestbib.bib}
@book{goossens93,
author = {Frank Mittelbach and Michel Goossens and Johannes Braams
and David Carlisle and Chris Rowley},
title = {The {LaTeX} Companion},
year = {1993},
publisher = {Addison-Wesley},
address = {Reading, Massachusetts},
}
@BOOK{Kymissis__2009,
title = {Organic Field Effect Transistors - Theory, Fabrication and Characterization},
publisher = {Springer},
year = {2009},
author = {Kymissis, Ioannis},
abstract = {Organic Field Effect Transistors discusses the fundamental mechanisms
that apply to {OFETs} fabrication, operation, and characterization.
This unique book presents the state-of-the-art in organic field effect
transistors ({OFETs)} with ...},
file = {Snapshot:C:\Documents and Settings\haehlen_t\My Documents\Papers\Zotero\storage\KV3VMKEJ\978-0-387-92133-4.html:text/html},
isbn = {9780387921341},
keywords = {Circuits and Systems, Fabrication and Characterization, Organic Chemistry,
Organic Field Effect Transistors - Theory, Technology \& Engineering
/ Engineering (General)},
language = {English},
owner = {haehlen_t},
shorttitle = {Organic Field Effect Transistors},
timestamp = {2013.10.07},
url = {http://www.springer.com/engineering/circuits+%26+systems/book/978-0-387-92133-4}
}
\end{filecontents}
\documentclass{article}
\usepackage{hyperref}
\usepackage{natbib}
\usepackage{bibentry}
\usepackage{etoolbox}
\makeatletter
\let\ORIG@BR@c@bibitem\BR@c@bibitem
\apptocmd\ORIG@BR@c@bibitem{\endgroup}{}{}
\def\BR@c@bibitem{\begingroup\catcode`\%=12 \ORIG@BR@c@bibitem}
\makeatother
\nobibliography*
\begin{document}
A full in-text cite of
\begin{NoHyper}\bibentry{goossens93}\end{NoHyper}.
A regular citation of \cite{goossens93}.
Problematic cite \cite{Kymissis__2009}
\begin{NoHyper}\bibentry{Kymissis__2009}\end{NoHyper}
\bibliographystyle{plainnat}
\bibliography{mytestbib}
\end{document}
关于这个技巧的一些话。
该bibentry
包重新定义\bibitem
为使用内部宏\BR@c@bibitem
,该宏基本上抓取 的参数\bibitem
,然后将所有到达第一个空白行的内容作为其第二个参数。%
的参数中的 使\url
解析器感到困惑,无法看到 后面的右括号%
。
因此我们重新定义宏来分两个阶段完成工作:
它开设了一个小组;
在此组内,它将类别代码设置为
%
12,使其成为可打印字符;调用
\ORIG@BR@c@bibitem
最终的宏基本上是原始宏的副本\BR@c@bibitem
,唯一的变化是,在其工作结束时,它会发出与(新)发出的\endgroup
平衡的。\begingroup
\BR@c@bibitem