# biblatex: How to remove the parentheses around the year in authoryear style?

The standard authoryear style in biblatex puts parentheses around the year in the bibliography and no parentheses around in text citation years:

• Smith 2011 shows ... (citation)

• Smith, Joe (2011) ... (bibliography)

Is there a (simple) way to turn these into:

• Smith (2011) shows ... (citation)

• Smith, Joe. 2011. ... (bibliography)

-

Thanks to egreg's great answer to biblatex: Is it possible to patch macros created with \newbibmacro?, the solution to the present question is easy: Use the new \patchbibmacro command to selectively change the definition of the date+extrayear bibmacro however this definition looks like in the first place (provided some common patterns are present).

\documentclass{article}

\usepackage[style=authoryear]{biblatex}

% By courtesy of Enrico Gregorio (egreg)
\makeatletter
\def\act@on@bibmacro#1#2{%
\expandafter#1\csname abx@macro@\detokenize{#2}\endcsname
}
\def\patchbibmacro{\act@on@bibmacro\patchcmd}
\def\pretobibmacro{\act@on@bibmacro\pretocmd}
\def\apptobibmacro{\act@on@bibmacro\apptocmd}
\def\showbibmacro{\act@on@bibmacro\show}
\makeatother

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
\end{filecontents}

\nocite{*}

\begin{document}

\printbibliography

\patchbibmacro{date+extrayear}{%
\printtext[parens]%
}{%
\printtext%
}{}{}

\printbibliography

\end{document}

EDIT: Things are even easier with egreg's xpatch package:

\documentclass{article}

\usepackage[style=authoryear]{biblatex}

\usepackage{xpatch}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
\end{filecontents}

\nocite{*}

\begin{document}

\printbibliography

\xpatchbibmacro{date+extrayear}{%
\printtext[parens]%
}{%
\printtext%
}{}{}

\printbibliography

\end{document}

-

UPDATE: A better solution for the bibliography may be found here.

In-text-citations: Replace \cite with \textcite.

Bibliography: From my personal biblatex.cfg (plus \makeatletter/\makeatother):

\makeatletter
\ifcsundef{abx@macro@\detokenize{date+extrayear}}{%
}{%
\renewbibmacro*{date+extrayear}{%
\iffieldundef{year}{%
}{%
\printtext{\printdateextra}%
}%
}%
}
\makeatother

(One could also simply redefine the date+extrayear bibmacro, but this would cause an error in case one switches to a style that doesn't feature this particular macro.)

EDIT: Alan Munn has brought my attention to the fact that my redefinition is based on an outdated version of authoryear.bbx which is by mistake still included in the biblatex version coming with MiKTeX. With a correctly installed biblatex version, my "solution" may or may not work for you.

EDIT 2: MiKTeX isn't the culprit. My preferred editor (TeXworks) somehow displays the contents of a former (!) version of authoryear.bbx.

EDIT 3: It seems that my redefinition will work with the default setting of the authoryear style, but is likely to break things if you tinker with the mergedate option (which was improved in biblatex v1.1b).

-
Thanks. For (1) I should have RTFM better. For (2) this is the kind of thing that I never know where in the various parts of the biblatex code to look to find things like this. I couldn't seem to find a definition like yours in biblatex.def, authoryear.bbx or biblatex.sty. This makes biblatex hacking quite frustrating. –  Alan Munn Feb 27 '11 at 21:41
@Alan: In fact, you missed it in authoryear.bbx. I agree that biblatex necessitates a STFF (scan the f*** files) approach. –  lockstep Feb 27 '11 at 21:46

The following answer to the second part of my question is based on discussions with lockstep in chat where we discovered that there have been significant changes to how dates are formatted in bibtex v1.1b which make his original answer potentially problematic. I thank him for his help.

For the first part of the question, his answer stands: to get parentheses around in-text citation years, use the \textcite family of commands.

To remove the parentheses from the bibliography years requires significant modification to the .bbx file. (I describe the modifications schematically here.) The actual modification should ideally be part of a separate .bbx file.

The biblatex authoryear.bbx file contains the following code to format various date fields. (This is just one of 5 such blocks of code: \bbx@opt@mergedate@maximum, compact, basic, minimum and false.)

\def\bbx@opt@mergedate@basic{%
\renewbibmacro*{date+extrayear}{%
\iffieldundef{year}
{}
{\printtext[parens]{%
\printfield{labelyear}%
\printfield{extrayear}}}}%
\renewbibmacro*{date}{%
\iffieldundef{month}
{}
{\printdate}}%
\renewbibmacro*{issue+date}{%
\ifboolexpr{
test {\iffieldundef{issue}}
and
test {\iffieldundef{month}}
}
{}
{\printtext[parens]{%
\printfield{issue}%
\printdate}}%
\newunit}%
}

The relevant part of the code that formats the year field is:

\renewbibmacro*{date+extrayear}{%
\iffieldundef{year}
{}
{\printtext[parens]{%
\printfield{labelyear}%
\printfield{extrayear}}}}

Notice that the two \printfield commands are enclosed in a \printtext[parens] command. This is the command that needs to be changed. So we redefine it without the [parens] format, and additionally we add punctuation and a space (which will appear right after the author name). This is needed because in styles that don't parenthesize the year, both author and year need to be punctuated.

So the redefined code is:

\renewbibmacro*{date+extrayear}{%
\iffieldundef{year}
{}
{\printtext{%
\printfield{extrayear}}}}

The same change needs to be made in each of the \bbx@opt@mergedate@... commands.

To make these changes take effect, the .bbx file must also have the line:

\ExecuteBibliographyOptions{labelyear,sorting=nyt,pagetracker,mergedate}

Additionally, the following needs to be added to the .bbx file to correctly format the extra year field when the year is non-numeric. (Based on lockstep's answer to this question: How to format the extrayear field in biblatex.

\DeclareFieldFormat{extrayear}{%
\iffieldnums{labelyear}{%
\mknumalph{#1}%
}{%
\mkbibparens{\mknumalph{#1}}%
}%
}

It would be nice if this sort of change would not take such low-level programming, but could be a user option. But for now this seems to be the best way to achieve it.

-

The natbib package has option \citealt{...} and citealp{...} (amongst others), which remove parentheses for in-text citations.

There is a great reference sheet that describes the suppressed parenthesis methods.

Copied from the above reference sheet:

\citealt{jon90}         -->     Jones et al. 1990
\citealt*{jon90}        -->     Jones, Baker, and Williams 1990
\citealp{jon90}         -->     Jones et al., 1990
\citealp*{jon90}        -->     Jones, Baker, and Williams, 1990
\citealp{jon90,jam91}   -->     Jones et al., 1990; James et al., 1991
\citealp[pg. 32]{jon90} -->     Jones et al., 1990, pg. 32
\citetext{priv. comm.}  -->     (priv. comm.)

Though this does not directly answer what you appear to be after in the question, I found this question when looking for in-text citation methods, and thought I'd share it for others looking for the same.

-

If you have parenthesis only around years, there is even a simpler way, by redefining the parenthesis punctuation. For instance, if you want the year enclosed in commas instead of parenthesis, you can have: