4

Usually citations use parentheses or square brackets in all cases. SBC (Brazilian Computer Society) has an odd case. Its style for references use parentheses everywhere, except when making parenthetical citations. In the case of parenthetical citations, one must use square brackets: [AuthorX 1999].

As an minimal working example:

\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}

How can I change only the \cite behavior of apacite to use square brackets, while maintaining all other apacite commands to still use parentheses?

6
  • Welcome to TEX.SE. Add a MWE, please.
    – Sebastiano
    Dec 20, 2016 at 16:43
  • Added a MWE, as requested. Dec 20, 2016 at 17:04
  • Are you sure you want ([Author 1999]) and not (Author [1999])? I.e, should the brackets be around the whole author+year or just around the year?
    – Alan Munn
    Dec 20, 2016 at 21:21
  • It's only [AuthorX 1999]. Dec 20, 2016 at 21:22
  • So no parentheses at all, just square brackets instead of parentheses?
    – Alan Munn
    Dec 20, 2016 at 21:23

1 Answer 1

3

You can modify the internal \@cite command so that it changes the brackets in just those cases.

\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}

output of code

1
  • @EdsonCésar I've updated the answer with a version that requires a lot less code. Since the addition is quite simple, it's nicer to use the etoolbox patching facilities to add the code. Then you don't need to copy the whole command.
    – Alan Munn
    Dec 20, 2016 at 21:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .