引文包含括號內的文字和分號

引文包含括號內的文字和分號

我的問題非常類似於這個。使用已接受答案的一部分作為我的問題的參考,

\begin{filecontents*}{\jobname.bib}
@book{01,
 author={Caesar, Gaius Iulius},
 title={Commentarii de bello {Gallico}},
 year={703},
}
\end{filecontents*}
\documentclass{article}

\makeatletter
\let\cite\relax
\DeclareRobustCommand{\cite}{%
  \let\new@cite@pre\@gobble
  \@ifnextchar[\new@cite{\@citex[]}}
\def\new@cite[#1]{\@ifnextchar[{\new@citea{#1}}{\@citex[#1]}}
\def\new@citea#1{\def\new@cite@pre{#1}\@citex}
\def\@cite#1#2{[{\new@cite@pre\space#1\if\relax\detokenize{#2}\relax\else, #2\fi}]}
\makeatother

\begin{document}

Here's a citation \cite[See:][p.~2]{01}

Another: \cite[p.~3]{01}.

Another: \cite{01}.

Again: \cite[See:][]{01}

\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

產生 在此輸入影像描述

但是,我不想在渲染文件中的前兩行使用逗號,而是使用分號。我將如何實現這個目標?

答案1

The,位於 的定義中\@cite,最後一行之前\makeatother,就在 af 後面\else。將逗號替換為分號:

樣本輸出

\begin{filecontents*}{\jobname.bib}
@book{01,
 author={Caesar, Gaius Iulius},
 title={Commentarii de bello {Gallico}},
 year={703},
}
\end{filecontents*}
\documentclass{article}

\makeatletter
\let\cite\relax
\DeclareRobustCommand{\cite}{%
  \let\new@cite@pre\@gobble
  \@ifnextchar[\new@cite{\@citex[]}}
\def\new@cite[#1]{\@ifnextchar[{\new@citea{#1}}{\@citex[#1]}}
\def\new@citea#1{\def\new@cite@pre{#1}\@citex}
\def\@cite#1#2{[{\new@cite@pre\space#1\if\relax\detokenize{#2}\relax\else; #2\fi}]}
\makeatother

\begin{document}

Here's a citation \cite[See:][p.~2]{01}

Another: \cite[p.~3]{01}.

Another: \cite{01}.

Again: \cite[See:][]{01}

\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

順便bibtex警告一下,這項工作缺少出版商:-)

相關內容