[Tex/LaTex] Citing in APA style with year in brackets

apa-styleciting

I'm writing my master thesis and citing in the APA style. Below is a picture how it looks right now:

citation

While it looks fine in general, I would like to alter the year and put it in brackets. Furthermore, erase the comma that comes after the author but leave the one that comes after the year so that it the final version looks like that:

Ruoff et al. (1953), p. 16

Because I copied the code to bring it to the near-final version I don't know how to alter it further to bring it to the wanted form.

The code that I have in the preamble looks as follows:

\documentclass[12pt]{report}
\usepackage{natbib}

\makeatletter
\newcommand*{\ibid}{Ibid.}
  \let\@predcite\@empty
  \let\@currcite\@empty
\def\citef{\kernel@ifnextchar[\citef@{\citef@[]}}
\def\citef@[#1]{\kernel@ifnextchar[{\citef@@[{#1}]}{\citef@@[][{#1}]}}
\def\citef@@[#1][#2]#3{%
  \def\@currcite{#3}%
  \unskip
    \ifx\@currcite\@predcite
      \footnote{#1 \ifx\tempa\@empty\unskip\fi%
      \ibid\ifx\tempb\@empty\else\NAT@cmt #2\fi}%
    \else%
      \footnote{\citealp[#1][#2]{#3}}%
    \fi
  \gdef\@predcite{#3}%
}
\makeatother

\bibliographystyle{apalike}

Furthermore, I cite like this in the text (this is for the example shown in the picture above):

\citef[p. 16]{ruoff53}

In advance, thank you so much for your advice. Your help is greatly appreciated!

EDIT:

After Bernard's tips I have now the following code:

Can you give me further hints? I altered the body of my text to the following, bit it seems to be a complete mess…

\documentclass[12pt]{report}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa,backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\addbibresource{biblio.bib}
\usepackage{rotating}

\makeatletter
\newcommand*{\ibid}{Ibid.}
  \let\@predcite\@empty
  \let\@currcite\@empty
\def\citef{\kernel@ifnextchar[\citef@{\citef@[]}}
\def\citef@[#1]{\kernel@ifnextchar[{\citef@@[{#1}]}{\citef@@[][{#1}]}}
\def\citef@@[#1][#2]#3{%
  \def\@currcite{#3}%
  \unskip
    \ifx\@currcite\@predcite
      \footnote{#1 \ifx\tempa\@empty\unskip\fi%
      \ibid\ifx\tempb\@empty\else\NAT@cmt #2\fi}%
    \else%
      \footnote{\citealp[#1][#2]{#3}}%
    \fi
  \gdef\@predcite{#3}%
}
\makeatother

\begin{document}


\chapter{Introduction}
\input{ma_chapters/introduction}
.
.
.
.

\bibliographystyle{apalike}
\bibliography{biblio}

Best Answer

Assuming you're OK with the apalike bibliography style, the natbib citation management package, and BibTeX in general, you could create a new macro that implements your desired citation callout format.

\newcommand\mycite[2][]{\citeauthor{#2}\ (\citeyear{#2})\ifx#1\undefined\else, #1\fi}

If the first, optional argument isn't specified, nothing is printed after \citeyear{#2}; in effect, if no optional argument is provided, \mycite behaves like \citet would.

enter image description here

\documentclass[12pt]{report}
\usepackage{filecontents}
\begin{filecontents}{biblio.bib}
@article{ruoff,
  author = "A. Ruoff and B. Woof and C. Zoot",
  title  = "Thoughts",
  journal= "Circularity Today",
  year   = 1953,
}
\end{filecontents}
\usepackage{natbib}
\bibliographystyle{apalike}
\newcommand\mycite[2][]{%
  \citeauthor{#2}\ (\citeyear{#2})\ifx#1\undefined\else, #1\fi}
\begin{document}
\mycite[p.~16]{ruoff}  % with optional argument

\mycite{ruoff}  % without optional argument -- no comma is printed

\citet{ruoff}   % compare with output of "\citet"
\bibliography{biblio}
\end{document}

Addendum: To place these citation callouts in a footnote, you could use a macro such as \myfootcite, defined as follows:

\newcommand\myfootcite[2][]{\footnote{\mycite[#1]{#2}.}}

If you don't want the period ("full stop") at the end of the footnote material, just omit the . after {#2}.


Second addendum, to accommodate the OP's request for a citation macro that prints out "Ibid." if the latest entry is the same as that from the preceding citation command:

Compared with the earlier solution, all that's required is to add a test if the current citation's key is the same as the one used in the previous citation. The following code provides two user macros: \tcite, for in-text citations, and \fcite, for in-footnote citations.

enter image description here

\documentclass[12pt]{report}
\usepackage[textheight=2in]{geometry} %% just for this example
\usepackage{filecontents}
\begin{filecontents}{biblio.bib}
@article{ruoff,
  author = "A. Ruoff and B. Woof and C. Zoot",
  title  = "Thoughts",
  journal= "Circularity Today",
  year   = 1953,
}
@article{abc,
  author = "Anna Andersen and Bertha Branson and Carla Carlsson",
  title  = "Further Thoughts",
  journal= "Circularity Today",   
  year   = 2053,
}
\end{filecontents}

\usepackage{natbib}
\bibliographystyle{apalike}
\def\prevcite{} % initialize \prevcite
%% macro for in-text citation
\newcommand\tcite[2][]{%  
  \def\newcite{#2} 
  \ifx\prevcite\newcite 
    Ibid.%
  \else%
    \gdef\prevcite{#2}% update \prevcite
    \citeauthor{#2}\ (\citeyear{#2})%
  \fi
  \ifx#1\undefined\else, #1\fi}
%% macro for in-footnote citation
\newcommand\fcite[2][]{\footnote{\tcite[#1]{#2}}}
\begin{document}


bla bla\fcite{ruoff}

more bla bla\fcite[p.~75]{ruoff}

still more bla bla\fcite[p.~101]{abc}

further bla bla\fcite{abc}

final bla bla\fcite[p.~999]{abc}
\bibliography{biblio}
\end{document}
Related Question