
據我了解,如果我想同時使用 doi 套件和 hyperref 的 pagebackref=true 設置,我需要先加載 hyperref (因為否則 doi 會加載它,並且 pagebackref=true 隨後無法通過 \hypersetup 設定) ,像這樣:
\usepackage[pagebackref=true]{hyperref}
\usepackage{doi}
但是,當我這樣做時,doi 包不再能夠轉義某些字符,例如下面的最小示例中“COLI_a_00057”中的雙下劃線:
\documentclass{article}
% Remove the {hyperref} line below to get this to compile
\usepackage[pagebackref=true]{hyperref}
\usepackage{doi}
\begin{document}
\cite{fort:cl11}
\begin{thebibliography}{1}
\bibitem[{Fort et~al.(2011)Fort, Adda, and Cohen}]{fort:cl11}
Fort, Karën; Gilles Adda; and K.~Bretonnel Cohen (2011).
\newblock {Amazon Mechanical Turk}: Gold mine or coal mine?
\newblock \emph{Computational Linguistics}, 37(2):413--420.
\newblock \doi{10.1162/COLI_a_00057}.
\end{thebibliography}
\end{document}
如果我包含此行 \usepackage[pagebackref=true]{hyperref}
我得到這樣的錯誤輸出(帶有指向第 1 頁的有效反向連結):
! Missing $ inserted.
<inserted text>
$
l.15
?
! Double subscript.
<argument> \Hy@safe@activesfalse 10.1162/COLI_a_
00057
l.15
?
! Missing $ inserted.
<inserted text>
$
l.15
如果我刪除它,我會得到一個有效的參考書目條目,其中包含指向 10.1162/COLI_a_00057 的 DOI 鏈接,但(顯然)沒有反向鏈接。
我可以在 pagebacklinks=true 中同時使用 doi 和 hyperref 嗎?
答案1
backref
用於此選項的套件會pagebackref
更改參考書目中的目錄代碼以查找參考書目條目的結尾。這會破壞所有依賴特定目錄程式碼(例如 URL、逐字文字和 DOI)的內容。如手冊中所解釋的,backref
可以使用 暫停catcode 更改\backrefparscanfalse
,但是您有責任告訴backref
您的參考書目條目在哪裡結束,並且可以編寫頁面列表。以下內容無需更改 DOI:
\documentclass{article}
\usepackage[pagebackref=true]{hyperref}
\usepackage{doi}
\begin{document}
\cite{fort:cl11}
\begin{thebibliography}{1}
\backrefparscanfalse
\bibitem[{Fort et~al.(2011)Fort, Adda, and Cohen}]{fort:cl11}
Fort, Karën; Gilles Adda; and K.~Bretonnel Cohen (2011).
\newblock {Amazon Mechanical Turk}: Gold mine or coal mine?
\newblock \emph{Computational Linguistics}, 37(2):413--420.
\newblock \doi{10.1162/COLI_a_00057}.
\backrefprint\backrefparscantrue
\end{thebibliography}
\end{document}
在可能的情況下,您並沒有真正thebibliography
手動設定環境,而是在 BibTeX 和一些參考書目風格的幫助下,請參閱這個答案如何變更參考書目樣式以在參考書目項目之前和之後自動插入\backrefparscanfalse
and命令。\backrefprint\backrefparscantrue