連續的數字式引文標註。為什麼 LaTeX 不創建數字範圍,例如“1-4”?

連續的數字式引文標註。為什麼 LaTeX 不創建數字範圍,例如“1-4”?

我在同一位置有多個引用,並且具有連續的引用編號,但 LaTeX 不使用連字符來連接第一個和最後一個。例如,

\documentclass[preprint,12pt]{elsarticle}
\begin{document}
    It has been shown in many experiments \cite{paper1,paper2,paper3,paper4} that ...

\bibliographystyle{elsarticle-num-names}
\bibliography{my_refs}
\end{document}

我想要的是“它已在許多實驗中顯示[1-4]”,但LaTeX給出的是“它已在許多實驗中顯示[1,2,3,4]”。

答案1

您已經設定了標籤“natbib”,所以我假設您正在使用natbib引文管理套件 - 以及可以產生數位式引文標註的參考書目樣式。

如果這些假設有效,您需要新增的只是compress在載入natbib套件時指定選項。

在此輸入影像描述

\documentclass{article} % or some other suitable document class

% Create a sample bib file on the fly:
\begin{filecontents}[overwrite]{mybib.bib}
@misc{paper1,author="A", title="B", year=3001}
@misc{paper2,author="C", title="D", year=3002}
@misc{paper3,author="E", title="F", year=3003}
@misc{paper4,author="G", title="H", year=3004}
\end{filecontents}

\usepackage[numbers,compress]{natbib}
\bibliographystyle{unsrtnat} % or some other suitable bib style

\begin{document}
\cite{paper1,paper2,paper3,paper4}
\bibliography{mybib}
\end{document}

附錄:為了回應這樣做的請求,OP 現在增強了查詢中提供的信息,以顯示正在使用哪個文檔類:elsarticle。由於此文件類別會natbib自動載入引文管理包,因此有必要將此選項指定compress為指令的參數\documentclass

\documentclass[preprint,12pt,compress]{elsarticle}

相關內容