如何防止哈佛風格 (agsm) 引用導致參考書目 URL 溢位到兩列?

如何防止哈佛風格 (agsm) 引用導致參考書目 URL 溢位到兩列?

我希望我的引用風格是哈佛。

我正在使用以下內容:

\documentclass[conference]{IEEEtran}
\usepackage[comma]{natbib}
\usepackage{url}
\begin{document}

foo \citep{vitz_history_2016}

\bibliographystyle{IEEEtran}
\bibliography{references}
\end{document}

引用文件中的範例.bib

@online{vitz_history_2016,
    year = {2016},
    title = {History of the Periodic Table},
    url = {https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table},
    titleaddon = {Chemistry {LibreTexts}},
    author = {Vitz, Ed and Moore, John and Shorb, Justin and Prat-Resina, Xavier and Wendorff, Tim and Hahn, Adam},
    urldate = {2019-11-25},
    date = {2016-05-26},
    langid = {english},
    file = {fname}
}

在兩列佈局中,這會產生: AGSM

我通常使用\cite{author}and創建文檔\bibliographystyle{IEEEtran},因此透過包含\usepackage{url}URL 可以正確顯示: 依依替尼

我希望第二個範例中出現相同的引用,但使用哈佛風格的引用,如第一個範例中那樣。

任何幫助將非常感激!

答案1

似乎有幾個問題。

  • 由於您使用的是IEEEtran文檔類,因此將IEEEtran參考書目樣式與套件一起使用應專門與和命令natbib結合使用;兩者都會產生數字式的引文標註。不適用於參考書目風格。\cite\citep\citetIEEEtran

  • 如果您希望將natbib套件與IEEEtran文件類別一起使用,您可能應該使用IEEEtranN參考書目樣式。 (NinIEEEtranN代表natbib...)透過這種設置,\cite並且\citep仍然會產生數字樣式的標註,但\citet現在也“有效”,因為它創建了作者-數位風格引用標註。儘管你可能會嘗試,但你不會讓這個設定產生作者-風格,又稱“哈佛風格”和“agsm 風格”,引文標註。

    也就是說,我會回應 @moewe 的評論:大多數(全部?!)需要使用IEEEtran文檔類的期刊都採用數字樣式的引文標註;他們可能會拒絕使用作者編號或作者年份風格的引用標註的提交內容。

  • 以防萬一這不是拼字錯誤:正確的語法是\citep{<some_key>}, 而不是\citep(<some_key>)

在此輸入影像描述

\documentclass[conference]{IEEEtran}

\begin{filecontents}[overwrite]{mybib.bib}
@online{vitz_history_2016,
    year = {2016},
    title = {History of the Periodic Table},
    url = {https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table},
    titleaddon = {Chemistry {LibreTexts}},
    author = {Vitz, Ed and Moore, John and Shorb, Justin and Prat-Resina, Xavier and Wendorff, Tim and Hahn, Adam},
    urldate = {2019-11-25},
    date = {2016-05-26},
    langid = {english},
    file = {fname}
}
\end{filecontents}

\usepackage[numbers,comma]{natbib}
\bibliographystyle{IEEEtranN} % not 'IEEEtran'
\usepackage{xurl}
\usepackage[colorlinks,allcolors=blue]{hyperref} % just for this example

\begin{document}
foo \citep{vitz_history_2016} % not "\citep(author)"

bar \citet{vitz_history_2016}
\bibliography{mybib}
\end{document}

附錄:我實際上可以重現看起來很糟糕的非斷行 URL 字串,用下標代替下劃線,如果我替換\bibliographystyle{IEEEtranN}為 ,則如您的第一個螢幕截圖所示\bibliographystyle{agsm}。這種agsm風格相當古老,並且使用了一個名為 的宏\harvardurl,它確實不是\url採取與排版 URL 字串時相同的預防措施;這些預防措施與 TeX 特殊字元有關,例如_%,它們可能出現在 URL 字串中。 (非常感謝@moewe向我指出了這一點!)

如果你必須使用agsm參考書目風格,那麼,有兩種方法可以進行:首先,您可以提供說明

\renewcommand\harvardurl{\textbf{URL:} \url}

\bibliographystyle{agsm}。其次,你可以改變

url = {https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table},

url = {\url{https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table}}, 

當然,這兩種方法都假設您已經加載了一個合適的套件——url並且xurl想到了——它定義了一個「真正的」\url巨集。

順便說一下,如果你想使用agsm參考書目風格,你應該加載har2nat包,而不是natbib直接加載包。為什麼?這agsm款式是哈佛大學引文管理包,它附帶了一些專門的命令。包har2nat(a) 載入natbib包並 (b) 將harvard特定宏「翻譯」為natbib包識別的宏。如果您希望hyperref在文件中使用該包,這尤其有用:hyperref與該包完全相容natbib,但與該包不太相容harvard

在此輸入影像描述

\documentclass[conference]{IEEEtran}

\begin{filecontents}[overwrite]{mybib.bib}
@online{vitz_history_2016,
    year = {2016},
    title = {History of the Periodic Table},
    url = {\url{https://chem.libretexts.org/Bookshelves/Ancillary_Materials/Exemplars_and_Case_Studies/Exemplars/Culture/History_of_the_Periodic_Table}},
    titleaddon = {Chemistry {LibreTexts}},
    author = {Vitz, Ed and Moore, John and Shorb, Justin and Prat-Resina, Xavier and Wendorff, Tim and Hahn, Adam},
    urldate = {2019-11-25},
    date = {2016-05-26},
    langid = {english},
    file = {fname}
}
\end{filecontents}

\usepackage{har2nat} % not 'natbib' directly
\bibliographystyle{agsm}
\usepackage{xurl}
\usepackage[colorlinks,allcolors=blue]{hyperref} 

\begin{document}
foo \citep{vitz_history_2016} % not "\citep(author)"

bar \citet{vitz_history_2016}
\bibliography{mybib}
\end{document}

相關內容