1

I'm using Overleaf, the preamble related to my bib is:

\usepackage{natbib}
\bibliographystyle{plainnat}

In the document I'd like to call citation in the form of (Hoek, 2007). I've managed to do it, but it's a bit long and annoying to type in text:

(\citeauthor{hoek2007}, \citeyear{hoek2007})

I'm new to commands, I made an attempt but the Overleaf commands explanation is going over my head. What I tried:

\newcommand{\citeay}[1]{(\citeauthor{#1}, \citeyear{#1})}

But the result of \citeay{hoek2007} is just [1].

  • Welcome to TeX.SX! With your \citeay command defined this way, there should be no problem and you should get the expected result. Could you post a minimal working example so we can see where the problem comes from? Working on a minimal example could even help you to solve the problem yourself! :) – Vincent Jan 9 at 4:45
  • 1
    Load natbib as \usepackage[authoryear,round]{natbib} and use \citep. You shouldn't have to define something like \citeay natbib supports author-year citations out of the box. If that doesn't help I suggest you add a full MWE (tex.meta.stackexchange.com/q/228/35864, tex.meta.stackexchange.com/q/4407/35864) to your question that shows exactly what you are doing at the moment. – moewe Jan 9 at 7:23
  • 1
    As an aside it is weird that (\citeauthor{hoek2007}, \citeyear{hoek2007}) in the text should work but \newcommand{\citeay}[1]{(\citeauthor{#1}, \citeyear{#1})} in the preamble and then \citeay{hoek2007} in the document not. They should give exactly the same result. (Unless something redefines \citeay later on. But we can only help with that if we see an MWE.) – moewe Jan 9 at 7:26
  • Do make sure to load the natbib package with the option authoryear if you wish to get authoryear-style citation callouts. – Mico Jan 9 at 7:37
0

But the result of \citeay{hoek2007} is just [1]. :-(

You need to load the natbib package with the options authoryear and round:

\usepackage[authoryear,round,<other options>]{natbib}

In the document I'd like to [create citation call-outs of] the form of (Hoek, 2007).

No need to create the macro you call \citeay. Just use natbib's \citep macro (short for "parenthetic-style citation call-out", I suppose).

|improve this answer|||||
0

I was going to type this in a comment but I didn't know how to format comments on StackExchange.

In writing the MWE I found the source of the problem:

\documentclass{article}
%\documentclass{revtex4-1}


\usepackage[utf8]{inputenc}
\usepackage[authoryear,round]{natbib}
\bibliographystyle{plainnat}

\begin{document}
Some words and stuff. \citep{hoek2007}.

\bibliography{sample}
\end{document}

When using \documentclass{article} \citep{...} produces the desired (Hoek, 2007). But when I used \documentclass{revtex4-1} for some reason it overrides it (I was using this documentclass because I was using a template). Hence that was, at least one of the things that clashed according to the error message on Overleaf:

LaTeX Error: Option clash for package natbib.
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.