通常情况下,引用都使用括号或方括号。SBC(巴西计算机协会)有一个奇怪的例子。其参考文献的风格在任何地方都使用括号,除了在括号内的引用。在括号内的引用时必须使用方括号:[AuthorX 1999]。
作为一个最小的工作示例:
\documentclass{article}
\usepackage{apacite}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = 1986,
title = {The \TeX book},
}
\end{filecontents}
\begin{document}
\section{Demonstration}
To adhere to SBC (Brazilian Computer Society) style:
This citation should be using square brackets:~\cite{Knu86}.
This should be using parentheses:~\citeA{Knu86}.
And this citation should be using square brackets:~\cite{Knu86}.
References should also be using parentheses!
\bibliographystyle{apacite}
\bibliography{\jobname}
\end{document}
我怎样才能仅将 apacite 的 \cite 行为更改为使用方括号,同时保持所有其他 apacite 命令仍然使用括号?
答案1
您可以修改内部\@cite
命令,以便它只在这些情况下更改括号。
\documentclass{article}
\usepackage{apacite}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = 1986,
title = {The {\TeX{ book},
}}}
\end{filecontents}
%
\makeatletter
\usepackage{etoolbox}
\makeatletter
\pretocmd{\@cite}{\def\@BBOP{[}\def\@BBCP{]}}{}{}
\makeatother
\makeatother
\begin{document}
\section{Demonstration}
To adhere to SBC (Brazilian Computer Society) style:
This citation should be using square brackets:~\cite{Knu86}.
This should be using parentheses:~\citeA{Knu86}.
And this citation should be using square brackets:~\cite{Knu86}.
References should also be using parentheses!
\bibliographystyle{apacite}
\bibliography{\jobname}
\end{document}