1

Description of problem

I have a problem with displaying bibliography citations two different ways with \cite and \citep commands. Below I describe my problem, give an example code and show the result I get from compiling.

I am using TeX Live with TeXmaker (Ubuntu 18.04), Biber installed for bibliography. I require the alphabetic style, which works as required with the command \cite{}. For example with \cite{Hecht10} references have brackets [Hec10], this is what I want. But then I also want to cite references with parenthesis. I would like something like this : "See the work of Hecht (2010) for more details". I tried \citep{Hecht10} and \parencite{Hecht10} but it still writes [Hec10].

MWE

\documentclass[
11pt,
twoside, 
english,
onehalfspacing,
toctotoc,
headsepline,
]{MastersDoctoralThesis}
\usepackage[autostyle=true]{csquotes}

\usepackage[ natbib=true, backend=biber, style=alphabetic, %numeric draft sorting=none ]{biblatex} \addbibresource{bibliographie.bib}

\begin{document}

See the work of \citep{Hecht10} for more details on laser developments \cite{Hecht10}.

\end{document}

Output

The result of this code is as follows:

See the work of [Hec10] for more details on laser developments [Hec10].

What I want

But I would like:

See the work of Hecht (2010) for more details on laser developments [Hec10].

The idea is then to remove the second and last \cite{}. So I will have two kind of bibliography calls in my document, "[name]" and "name (year)" called respectively with \cite{} and \citep{}, or whatever command I haven't been aware of.

moewe
  • 175,683

3 Answers3

2

First of all, when using BibLaTeX, use \cite, \autocite, and \parencite instead of \citet and \citep.

There are way more elegant options, but this works:

\usepackage[style=authoryear]{biblatex}

\DeclareCiteCommand*{\parencite}[] {\usebibmacro{prenote}} {\usebibmacro{citeindex}% \usebibmacro{author} \bibopenparen\usebibmacro{citeyear}\bibcloseparen} {\multicitedelim} {\usebibmacro{postnote}}

You can then cite using \parencite*{Hecht10}. Note the asterisk though ;-).

skowalak
  • 121
1

Biblatex provides commands like \citeauthor{mysource} and \citeyear{mysource}. These print only the author and year fields respectively. You can combine them, and modify the \citep command to mean this combination:

\renewcommand\citep[1]{%
    \citeauthor{#1}~(\citeyear{#1})%
}

Citep renewed output

Then use \citep as wanted:

See the work of \citep{Hecht10} for more details on laser developments \cite{Hecht10}.

(The tilde (~) is a non-breaking space. It prints like a space, but the second part should never wrap to the next line with the first part remaining at the end of the previous line. The percent signs prevent extra whitespace, for example see what happens if you remove them and try to use See \citep{Hecht10}..)

Has this answer helped you?

  • Combining two \cite... calls into one \newcommand has two drawbacks: Without a bit of trickery it does not deal properly with pre- and postnotes and multiple citations (try \citep{sigfridsson,worman} or extend it to work for \citep[Cf.][380]{sigfridsson} and \citep[372]{sigfridsson}). Additionally, this has the potential to confuse biblatex's citation tracked (for ibid etc.). – moewe May 25 '21 at 15:27
  • @moewe Sure. But both are fixable and this approach is very flexible. I think we have a nice combo of answers. Yours explaining the semantics and to think twice before deviating from the standard. Mine explaining how it can be achieved when you insist doing it as requested. – Vincent Kuhlmann May 25 '21 at 16:01
  • Mhh yes. But to some extent fixing the problems would involve reinventing what biblatex does internally with \DeclareCiteCommand. I will admit that the \DeclareCiteCommand approach usually takes quite a few more lines than putting together \...cite... commands in a \newcommand, but with the former you can be sure that biblatex takes care of the tricky things. – moewe May 25 '21 at 19:34
  • @moewe Yeah, good finds of skowalak. Didn't know about these commands. Going to give him an upvote – Vincent Kuhlmann May 25 '21 at 19:58
1

Generally, the two commands you want to look for are called \textcite and \parencite.

\parencite is used for parenthetical references (usually at the end of a sentence), while \textcite is used for textual/narrative citations where the author is part of the sentence.

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

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

\addbibresource{biblatex-examples.bib}

\begin{document} See the work of \textcite{sigfridsson} for more details on laser developments.

Lasers are very interesting \parencite{worman}.

\printbibliography \end{document}

See the work of Sigfridsson and Ryde [SR98] for more details on laser developments.//Lasers are very interesting [Wor02].

With the alphabetic style, \parencite produces the alphanumerical citation label and \textcite produces the author name followed by the alphanumerical citation label in brackets. This results in the same work being cited to uniformly with the same label in all situations.

I would recommend against having \textcite print the year instead of the alphanumeric citation label, since that may not be enough to identify an entry uniquely or would lead to a mixture of two different citation styles.

If you are planning on \parenciteing the publication at the end of the sentence anyway and the sentence is not too long, you may want to consider using \citeauthor instead of \textcite.

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

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

\addbibresource{biblatex-examples.bib}

\begin{document} See the work of \citeauthor{sigfridsson} for more details on laser developments \parencite{worman}.

Lasers are very interesting \parencite{worman}.

\printbibliography \end{document}


If you insist on "Author (Year)" citations for a textcite-like command we can steal the relevant code from authoryear.cbx (I added an ay: to the macro names to avoid name clashes)

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

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

\newbibmacro*{ay:citeyear}{% \iffieldundef{shorthand} {\iffieldundef{labelyear} {\usebibmacro{ay:cite:label}} {\usebibmacro{ay:cite:labeldate+extradate}}} {\usebibmacro{ay:cite:shorthand}}}

\newbibmacro*{ay:textcite}{% \ifnameundef{labelname} {\iffieldundef{shorthand} {\usebibmacro{ay:cite:label}% \setunit{% \global\booltrue{cbx:parens}% \printdelim{nonameyeardelim}\bibopenparen}% \ifnumequal{\value{citecount}}{1} {\usebibmacro{prenote}} {}% \usebibmacro{ay:cite:labeldate+extradate}} {\usebibmacro{ay:cite:shorthand}}} {\printnames{labelname}% \setunit{% \global\booltrue{cbx:parens}% \printdelim{nameyeardelim}\bibopenparen}% \ifnumequal{\value{citecount}}{1} {\usebibmacro{prenote}} {}% \usebibmacro{ay:citeyear}}}

\newbibmacro*{ay:cite:shorthand}{% \printtext[bibhyperref]{\printfield{shorthand}}}

\newbibmacro*{ay:cite:label}{% \iffieldundef{label} {\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}} {\printtext[bibhyperref]{\printfield{label}}}}

\newbibmacro*{ay:cite:labeldate+extradate}{% \iffieldundef{labelyear} {} {\printtext[bibhyperref]{\printlabeldateextra}}}

\newbibmacro*{ay:textcite:postnote}{% \iffieldundef{postnote} {\ifbool{cbx:parens} {\bibcloseparen} {}} {\ifbool{cbx:parens} {\setunit{\printdelim{postnotedelim}}} {\setunit{\printdelim{extpostnotedelim}\bibopenparen}}% \printfield{postnote}\bibcloseparen}}

\DeclareCiteCommand{\aytextcite} {\boolfalse{cbx:parens}} {\usebibmacro{citeindex}% \iffirstcitekey {\setcounter{textcitetotal}{1}} {\stepcounter{textcitetotal}% \textcitedelim}% \usebibmacro{ay:textcite}} {\ifbool{cbx:parens} {\bibcloseparen\global\boolfalse{cbx:parens}} {}} {\usebibmacro{ay:textcite:postnote}}

\DeclareMultiCiteCommand{\aytextcites}{\aytextcite}{}

\addbibresource{biblatex-examples.bib}

\begin{document} See the work of \aytextcite{sigfridsson} for more details on laser developments \parencite{worman}.

Lasers are very interesting \parencite{worman}.

Lorem \aytextcite{knuth:ct:b} ipsum \aytextcite{knuth:ct:c}

\printbibliography \end{document}


If you use the natbib compatibility mode you can use \citep instead of \parencite and \citet instead of \textcite. But I usually recommend against this option. (Is there a disadvantage to using natbib=true with biblatex?)

moewe
  • 175,683