我的问题非常类似这个。在我的问题中使用部分已接受的答案作为参考,
\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
警告说这部作品缺少出版商:-)