0

I am a bit new to LaTeX etc. so please excuse me if this is a beginner question.

I would like to cite references within my document in the following style:

According to Powell et al. (2007)...

This is the best way to do it (Powell et al., 2007)

And so forth. To the best of my understanding, I want to use authoryear style to achieve this. The problem I'm having is getting the first result with the year in parentheses.

Here is my code:

\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{filecontents}
\addbibresource{\jobname.bib}
\usepackage[
backend=biber,
style=authoryear,
maxcitenames=2,
bibencoding=latin1
]
{biblatex}

\begin{filecontents}{\jobname.bib}

 @article{powell2007fastfood,
 title={The availability of fast-food and full-service restaurants in 
 the United States: associations with neighborhood characteristics},
 author={Powell, Lisa M and Chaloupka, Frank J and Bao, Yanjun},
 journal={American journal of preventive medicine},
 volume={33},
 number={4},
 pages={S240--S245},
 year={2007},
 publisher={Elsevier}
}
\end{filecontents}

\begin{document}

Here you see \cite{powell2007fastfood}
Here you can also see \parencite{powell2007fastfood}
Also, you have \textcite{powell2007fastfood}

\printbibliography
\end{document}

So the first two, \cite and \parencite, work. They produce the desired results of:

Here you see Powell et al. 2007

Here you can also see (Powell et al. 2007)

For \textcite, I have to manually type it in (using Texmaker provides an autocomplete or autosuggestion option) and then once I have typed the command, I also have to manually type the citation ID. Then when I compile, it gives me the error message "undefined control sequence." It's like the \textcite command is simply not recognized at all. What could cause this?

As an aside, I would prefer a style that put a comma between the author/et al. and year, so

Powell et al., 2007

But I am also trying to explore different citation styles to get what I want.

  • 1
    \textcite should work. You'll have to show us a complete example with the problem. Take a look at minimal working example with bibliography (MWEB) and minimal working example (MWE) to have an idea on how to prepare one. – gusbrs Feb 15 at 21:42
  • 3
    \citet (t at the ending of the command!) and \citep are defined with natbib To be able to use them add optionnatbib to biblatex. – Mensch Feb 15 at 21:54
  • Thank you for the suggestion. I have added an example. I hope that's enough for a MWE. I can also explore the natbib option. – Bkk Feb 16 at 17:46
  • The code shown so far is unfortunately not an MWE. Please have a look at tex.meta.stackexchange.com/q/228 and tex.meta.stackexchange.com/q/4407 to find out what makes an MWE. If I try to complete the code snippets into an MWE (gist.github.com/moewew/485cd2ecdaea88acca9f5c9b97227a00) the output is exactly as expected. Please turn your code into an MWE, run that MWE and copy and paste the error message you get from \textcite. – moewe Feb 16 at 17:51
  • I finally figured it out, although I'm still not sure why. A series of restarts and reopens. Although I still do not get an autocomplete suggestion for the command, and when I type \textcite it still does not offer me a list of references to choose from like the other commands. But at least it is compiling as desired now. – Bkk Feb 16 at 18:35
3

Most biblatex styles offer a variety of citation commands. You can find what all standard styles and therefore most contributed styles do in §3.8 Citation Commands and its subsections, pp. 100-110, of the biblatex documentation.

The following example shows the most common citation commands for authoryear styles

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\addbibresource{biblatex-examples.bib}

\begin{document}
\autocite{sigfridsson}

\cite{sigfridsson}

\parencite{sigfridsson}

\textcite{sigfridsson}

Lorem\footcite{sigfridsson}

\fullcite{sigfridsson}

\printbibliography
\end{document}

(Sigfridsson and Ryde 1998)//Sigfridsson and Ryde 1998//(Sigfridsson and Ryde 1998)//Sigfridsson and Ryde (1998)//Lorem footnote 1 to a full citation like the following//Emma Sigfridsson and Ulf Ryde (1998). ‘Comparison of methods for deriving atomic charges from the electrostatic potential and moments’. In: Journal of Computational Chemistry 19.4, pp. 377–395. doi: 10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P

The behaviour of the \autocite commands, whose use I can't recommend enough, can be configured freely. By default it behaves like \parencite or \footcite for most standard styles (it will behave like \footcite for styles of the authortitle and verbose style families and like \parencite for most other styles). But you can easily switch to footnote citation should you want to. Just have a look at the autocite option.

It does not matter whether or not those commands show up in some autocompletion feature of your editor. They are defined by all biblatex standard styles and all good contributed styles and should therefore work. If your editor's autocompletion does not display these commands, then that is something you can take up with the developers of the editor or the author of the autocomplete function. (But see also Auto-complete feature for Texmaker citations, Biblatex - Texmaker auto-complete commands.)

There is the natbib compatibility option that lets you use natbib's equivalent shorter names for \parencite and \textcite (namely \citep and \citet, respectively). I would normally try to avoid using that option since the handling of the starred forms of citation commands differ for the biblatex and the natbib names. Furthermore, the natbib compatibility mode changes the definition of nameyeardelim, which means that there will be a comma between author and year in \cite and \parencite/\citep. See also Is there a disadvantage to using natbib=true with biblatex?.


If you want to see a comma between author and year you can just set

\DeclareDelimFormat{nameyeardelim}{\addcomma\space}

the natbib compatibility mode is not required for that.

  • Thank you so much for this answer. Actually, reading through it, I would prefer a comma between author and year. Perhaps I should explore natbib. I am very new to bibliography options here. Having not gotten too far along in my current document, it may not be as cumbersome to switch? – Bkk Feb 16 at 17:56
  • @Bkk There is a (huge) difference between switching to natbib altogether and using the natbib compatibility option. In general I would suggest to stick with biblatex and only use the natbib compatibility option if you want to retain the old natbib names for compatibility with older documents. But there might be reasons to prefer natbib (if you have to use an existing .bst file or submit to a journal). You may be interested in tex.stackexchange.com/q/25701/35864 – moewe Feb 16 at 18:02
  • Thank you for the edit on how to put a comma in. That's hugely helpful. After reading the link and your suggestion, I will stick with not using natbib. – Bkk Feb 16 at 18:06
  • "The behaviour of the \autocite commands, whose use I can't recommend enough, can be configured freely, by default it behaves like \autocite." Did you mean "it behaves like \parencite"? – BrtH Feb 17 at 22:10
  • @BrtH Yup. Typo fixed and passage slightly clarified. Thanks for the hint. – moewe Feb 18 at 6:58

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.