# Biblatex, author-year, square brackets

I need to customize the author-year citation in biblatex for a template at work. Right now biblatex cites like this:

Ruschmeyer u. a. 1995, S. 123

They way I was told it needs to cite is:

[Ruschmeyer u. a. 1995, S. 123]

This seems pretty simple and I thought it would be done in a second, but after reading through the biblatex documentation for the second time, I still don't really have a clue.

An alternative to lockstep's solution is to redefine the high-level parentheses commands. With the default option setting parentracker=true, these are context-sensitive; nested parentheses may be set as brackets, depending on the nesting level.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear]{biblatex}

%\ExecuteBibliographyOptions{parentracker=false}

\makeatletter

\newrobustcmd*{\parentexttrack}[1]{%
\begingroup
\blx@blxinit
\blx@setsfcodes
\blx@bibopenparen#1\blx@bibcloseparen
\endgroup}

\AtEveryCite{%
\let\parentext=\parentexttrack%
\let\bibopenparen=\bibopenbracket%
\let\bibcloseparen=\bibclosebracket}

\makeatother

\begin{document}
\null\vfill\noindent
Filler text \parencite[see][59--63]{markey}. \\
Filler text \parencite[see][\pno~59 \parentext{last paragraph}]{markey}. \\
Filler text \parencite[see][\pno~59 \brackettext{last paragraph}]{markey}. \\
\parentext{Filler text \parencite[see][\pno~59 \parentext{last paragraph}]{markey}.} \\
\brackettext{Filler text \parencite[see][\pno~59 \parentext{last paragraph}]{markey}.} \\
\citeauthor{markey} show that this is filler text \parencite*{markey}. \\
\textcite[see][\pno~59 \parentext{last paragraph}]{markey} show that this is filler text. \\
Filler text \autocite{markey}. \\
\citeauthor{markey} show that this is filler text \autocite*{markey}. \\
Filler text.\smartcite[\pno~59 \brackettext{last paragraph}]{markey}
Filler text.\footnote{More filler text \smartcite[see][\pno~59 \brackettext{last paragraph}]{markey}.} \\
\parencites{markey,knuth:ct:b} \\
\textcites{markey,knuth:ct:b} \\
\printbibliography
\end{document}


• +1 for \ifcitation. This answer should become the accepted one. – lockstep Apr 27 '11 at 22:11
• And how do I get a bibliography in table style (the names in brackets on the left hand side and the informations about the references on the right hand side? – pirad Mar 23 '12 at 12:51
• @pirad This post might help. If that isn't what you had in mind, feel free to post a new question. – Audrey Mar 23 '12 at 14:46
• +1 for the nice solution. Still, I thought 'just' adding some brackets would not be so complicated with the newer biblatex... – Alexander May 11 '12 at 16:17
• @Alexander Complications arise in parenthesis tracking. If you don't use this feature, the simple solution I first posted should work. – Audrey May 11 '12 at 17:12

First, if you want brackets or parentheses, you should use \parencite{}, instead of \cite{}.

By default, this will produce round parentheses () in the author-year citation style. If you want square brackets [] instead, you can create your own .cbx file, and the easiest way is to modify an existing one. I provide an example at the end of the post.

(Note: Audrey's solution is simpler than this one, but it did not work when I tried it. This solution worked for me.)

Save the modified cbx file in your working directory as authoryearbrack.cbx, and then in your .tex file use:

\usepackage[bibstyle=authoryear,citestyle=authoryearbrak]{biblatex}


\usepackage[style=authoryear]{biblatex}


That should do it. If you are interested in creating your own .cbx files more generally, read on.

In a standard TeX Live distribution, with biblatex installed, you should find all the default biblatex .cbx files under texmf-dist/tex/latex/biblatex/cbx. For example, authoryear.cbx is for the basic author-year citation style, and you'll also find authoryear-comp.cbx, authoryear-ibid.cbx, etc.

In order to produce the file below, I started with authoryear.cbx and did just two things:

1. Changed every occurrence of \mkbibparens to \mkbibbrackets, and
2. Changed the comments and ProvidesFile lines at the top of the file to reflect the new file name.

Here is the modified version of authoryear.cbx which uses brackets instead of parentheses, and which you should save as authoryearbrack.cbx:

% $Id: authoryearbrack.cbx,v 1 anon$

\ProvidesFile{authoryearbrack.cbx}
[\abx@cbxid $Id: authoryearbrack.cbx,v 1 anon$]

\ExecuteBibliographyOptions{labelyear,uniquename,uniquelist,autocite=inline}
\newbool{cbx:parens}

\newbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
{\printnames{labelname}%
\setunit{\nameyeardelim}}%
\usebibmacro{cite:labelyear+extrayear}}
{\usebibmacro{cite:shorthand}}}

\newbibmacro*{citeyear}{%
\iffieldundef{shorthand}
{\iffieldundef{labelyear}
{\usebibmacro{cite:label}}
{\usebibmacro{cite:labelyear+extrayear}}}
{\usebibmacro{cite:shorthand}}}

\newbibmacro*{textcite}{%
\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labelyear+extrayear}}
{\usebibmacro{cite:shorthand}}}
{\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeyear}}}

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

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

\newbibmacro*{cite:labelyear+extrayear}{%
\iffieldundef{labelyear}
{}
{\printtext[bibhyperref]{%
\printfield{labelyear}%
\printfield{extrayear}}}}

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

\DeclareCiteCommand{\cite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{citeyear}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{citeyear}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\smartcite}[\iffootnote\mkbibbrackets\mkbibfootnote]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\textcite}
{\boolfalse{cbx:parens}}
{\usebibmacro{citeindex}%
\usebibmacro{textcite}}
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}%
\multicitedelim}
{\usebibmacro{textcite:postnote}}

\endinput

• What exactly "did not work" in Audrey's solution? – lockstep Dec 26 '11 at 23:59
• Taking a closer look at your solution, a) \bibopenparen/ \bibcloseparen should be replaced with \bibopenbracket/\bibclosebracket b) the result will closely mirror my answer. ;-) That said, welcome to tex.sx! – lockstep Dec 27 '11 at 0:10
• @Steve Did the problem relate to parenthesis tracking? If not, could you elaborate? – Audrey Dec 27 '11 at 6:03
• Thanks, but how can I make the bibliography section use square brackets as well? Right now it's like "Einstein (2017). Title" – Yan King Yin Nov 27 '17 at 5:20

(I suspect that a better solution will turn up.)

\documentclass{article}

\usepackage[style=authoryear]{biblatex}

\renewbibmacro*{textcite}{%
\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labelyear+extrayear}}
{\usebibmacro{cite:shorthand}}}
{\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeyear}}}

\renewbibmacro*{textcite:postnote}{%
\iffieldundef{postnote}
{\ifbool{cbx:parens}
{\bibclosebracket}
{}}
{\ifbool{cbx:parens}
{\setunit{\postnotedelim}}
\printfield{postnote}\bibclosebracket}}

\DeclareCiteCommand{\textcite}
{\boolfalse{cbx:parens}}
{\usebibmacro{citeindex}%
\usebibmacro{textcite}}
{\ifbool{cbx:parens}
{\bibclosebracket\global\boolfalse{cbx:parens}}
{}%
\multicitedelim}
{\usebibmacro{textcite:postnote}}

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{citeyear}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\smartcite}[\iffootnote\mkbibbrackets\mkbibfootnote]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\usepackage{filecontents}

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

\begin{document}

\textcite{A01}

\parencite{A01}

\autocite{A01}

\printbibliography

\end{document}


You could renew the command in order to introduce the brackets. This is a way to do it:

\let\oldcite\cite
\renewcommand*\cite[1]{[\oldcite{#1}]}

• Also that's a bad idea as you should at least use \mkbibbrackets or the like. – TeXnician Aug 25 '17 at 15:20
• While this might be acceptable for other bibliography(citatin packages it is a bad idea for biblatex. You will definitely lose the ability to use pre- and postnotes- (i.e. the optional arguments) that way. As TeXnician notes, hard-coding the brackets will make them invisible to biblatex's parentheses tracker, but that is probably not too bad here. – moewe Aug 25 '17 at 15:36

The styles of the biblatex-ext bundleDisclaimer: I'm the author. have a feature to change the parentheses around \parencite and friends easily.

\DeclareOuterCiteDelims{⟨cite command⟩}{⟨opening delimiter⟩}{⟨closing delimiter⟩}


redefines the outer citation delimiters of \⟨cite command⟩.

There is an analogous

\DeclareInnerCiteDelims{⟨cite command⟩}{⟨opening delimiter⟩}{⟨closing delimiter⟩}


for the 'inner' delimiter (the parentheses around the year in \textcite).

The bundle has one extended style for each standard style. The default settings are so that the ext-<standard style> style can be used as a drop-in replacement of <standard style> without changes in output.

To obtain square brackets for authoryear's \parencite one would load ext-authoryear and issue the following \DeclareOuterCiteDelims declaration.

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

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

\DeclareOuterCiteDelims{parencite}{\bibopenbracket}{\bibclosebracket}

\begin{document}
\autocite{sigfridsson} -- \parencite{sigfridsson}
\printbibliography
\end{document}


When you just want to but around braces in your cite, use

\usepackage{letltxmacro}\LetLtxMacro{\cite}{\parencite}


When you want to add a comma before the year, use

\renewcommand*{\nameyeardelim}{\addcomma\space}


(Answers taken from the duplicate question Redefine \cite for brackets)

\DeclareCiteCommand{\cite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}