引文用括号括起来,并用分号括起来

引文用括号括起来,并用分号括起来

我的问题非常类似这个。在我的问题中使用部分已接受的答案作为参考,

\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

位于,的定义中\@cite,即 之前的最后一行\makeatother,就在 之后\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警告说这部作品缺少出版商:-)

相关内容