# Configuring biblatex to put brackets around the year in citations

In a previous topic (Biblatex authoryear in brackets and with parenthesis around the year), it has been asked how to put the year in brackets when using authoryear citation in biblatex. When I apply the solution to my code, I get no space between each label and the next

One way to solve this is to modify the code in the previous question to include ;<space> after the command \usebibmacro{cite:shorthand}} (see the original question). This pretty much solves it

One last thing that I need is to remove the last delimiter because it should not be there since it is attached to the last label.

\begin{filecontents*}{sample.bib}
@ARTICLE{wu2017,
title={{Assessing Impact of Renewable Energy Integration on System Strength Using Site-Dependent Short Circuit Ratio}},
author={Wu, Di and Li, Gangan and Javadi, Milad and Malyscheff, Alexander M and Hong, Mingguo and Jiang, John Ning},
journal={IEEE Transactions on Sustainable Energy},
year={2017},
publisher={IEEE}
}
@article{wu2019method,
title={A method to identify weak points of interconnection of renewable energy resources},
author={Wu, Di and Aldaoudeyeh, Al~Motasem and Javadi, Milad and Ma, Feng and Tan, Jin and Jiang, John N and others},
journal={International Journal of Electrical Power \& Energy Systems},
volume={110},
pages={72--82},
year={2019},
publisher={Elsevier}
}
@INPROCEEDINGS{zhu2015,
author={Y. Zhu and D. Brown},
booktitle={2015 IEEE Power Energy Society General Meeting},
title={{Prepare to meet the challenges in regional transmission planning and development}},
year={2015},
volume={},
number={},
pages={1-5},
keywords={hydroelectric power;investment;power grids;power transmission economics;power transmission planning;power transmission reliability;regional planning;wind power;economical benefit analysis;federal right of first refusal removal;hydro power export;regional cost allocation;regional transmission development;regional transmission planning;system reliability enhancement;transmission investment;weak grid;wind energy delivery;wind energy energy export;Economics;HVDC transmission;Planning;Reactive power;Reliability;Voltage control;Wind farms;Competition;Economic Analysis;FERC Order 1000;Project Screening;Project Selection;ROFR;Regional Transmission Planning;Reliability Analysis;Renewable Energy;Transfer Limit;Weak Grid},
doi={10.1109/PESGM.2015.7286306},
ISSN={1932-5517},
month={July},
}
@inproceedings{lorenzen2016,
title={{Control of a grid connected converter during weak grid conditions}},
author={Lorenzen, S{\o}ren Lund and Nielsen, Alex Buus and Bede, Lorand},
booktitle={Power Electronics for Distributed Generation Systems (PEDG), 2016 IEEE 7th International Symposium on},
pages={1--6},
year={2016},
organization={IEEE}
}
@inproceedings{manjure2001,
title={{Steady state stability assessment using the bus impedance matrix}},
author={Manjure, DP and Makram, EB},
booktitle={Power Engineering, 2001. LESCOPE'01. 2001 Large Engineering Systems Conference on},
pages={153--157},
year={2001},
organization={IEEE}
}
\end{filecontents*}

\documentclass{book}

\usepackage[x11names]{xcolor}

\usepackage{hyperref}

\usepackage[style=authoryear-comp]{biblatex}

\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}

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

\makeatother

\begin{document}

\cite{wu2017,wu2019method}

\cite{zhu2015,lorenzen2016,manjure2001}

\printbibliography

\end{document}


This is one of the jobs that I wrote biblatex-ext for. With

\DeclareInnerCiteDelims{textcite}{\bibopenbracket}{\bibclosebracket}


you can tell \textcite to use square brackets instead of round parentheses for the year. You just need to load the ext- version of your style, so you would load style=ext-authoryear-comp instead of style=authoryear-comp. Everything else will remain as is.

I copied the \autocite\textcite mapping from David Purton's answer.

\documentclass{article}
\usepackage[style=ext-authoryear-comp]{biblatex}

\DeclareAutoCiteCommand{textcite}{\textcite}{\textcites}
\ExecuteBibliographyOptions{autocite=textcite}

\DeclareInnerCiteDelims{textcite}{\bibopenbracket}{\bibclosebracket}

\begin{document}
\autocite{knuth:ct:a,knuth:ct:b}

\autocite{knuth:ct:a,worman,sigfridsson}

\printbibliography
\end{document}


Of course biblatex-ext would also allow you to change \cite directly, but I avoided that since I believe your desired output is more \textcite-like.

\DeclareInnerCiteDelims{cite}{\bibopenbracket}{\bibclosebracket}


There are subtle differences in the placement of post- and pre-notes and citation delimiters between \textcite and \cite.

Your trouble comes from the fact that the cite macro is a little different in authoryear-comp to authoryear.

This also makes it more complicated to just put brackets around a year as they may be compressed.

I suggest making use of \textcite and patching the textcite macro to use brackets instead of parentheses. (There's probably a variety of ways of doing this depending on exactly what you want.)

To set the delimiter used in \textcite to a semicolon, use \renewcommand*{\textcitedelim}{\addsemicolon\space}

To make this the default, but still allow for flexibility in changing styles, I suggest you add an autocite style pointing to textcite and use \autocite everywhere, which can then be easily changed globally.

# MWE

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{wu2018,
title={Assessing Impact of Renewable Energy Integration on System Strength Using Site-Dependent Short Circuit Ratio},
author={Wu, Di and Li, Gangan and Javadi, Milad and Malyscheff, Alexander M and Hong, Mingguo and Jiang, John Ning},
journaltitle={IEEE Transactions on Sustainable Energy},
date={2018}
}
@article{wu2017,
title={Assessing Impact of Renewable Energy Integration on System Strength Using Site-Dependent Short Circuit Ratio},
author={Wu, Di and Li, Gangan and Javadi, Milad and Malyscheff, Alexander M and Hong, Mingguo and Jiang, John Ning},
journaltitle={IEEE Transactions on Sustainable Energy},
date={2017}
}
@article{wu2019method,
title={A method to identify weak points of interconnection of renewable energy resources},
author={Wu, Di and Aldaoudeyeh, Al~Motasem and Javadi, Milad and Ma, Feng and Tan, Jin and Jiang, John N and others},
journaltitle={International Journal of Electrical Power \& Energy Systems},
volume={110},
pages={72-82},
date={2019},
}
@inproceedings{zhu2015,
author={Y. Zhu and D. Brown},
booktitle={2015 IEEE Power Energy Society General Meeting},
title={Prepare to Meet the Challenges in Regional Transmission Planning and Development},
date={2015},
pages={1-5},
doi={10.1109/PESGM.2015.7286306},
ISSN={1932-5517},
month={July}
}
@inproceedings{lorenzen2016,
title={Control of a Grid Connected Converter During Weak Grid Conditions},
author={Lorenzen, Søren Lund and Nielsen, Alex Buus and Bede, Lorand},
booktitle={Power Electronics for Distributed Generation Systems (PEDG), 2016 IEEE 7th International Symposium on},
pages={1-6},
date={2016},
organization={IEEE}
}
@inproceedings{manjure2001,
title={Steady State Stability Assessment Using the Bus Impedance Matrix},
author={Manjure, DP and Makram, EB},
booktitle={Power Engineering, 2001. LESCOPE'01. 2001 Large Engineering Systems Conference on},
pages={153-157},
date={2001},
organization={IEEE}
}
\end{filecontents}

\documentclass{article}

\usepackage[style=authoryear-comp]{biblatex}

\DeclareAutoCiteCommand{textcite}{\textcite}{\textcites}
\ExecuteBibliographyOptions{autocite=textcite}

% You need to patch in a few places
\usepackage{xpatch}
\xpatchbibmacro{textcite}
{\bibopenparen}
{\bibopenbracket}
{}
{}
\xpatchbibmacro{textcite}
{\bibcloseparen}
{\bibclosebracket}
{}
{}
\xpatchbibmacro{textcite}
{\bibopenparen}
{\bibopenbracket}
{}
{}
\renewbibmacro*{textcite:postnote}{%
\usebibmacro{postnote}%
\ifthenelse{\value{multicitecount}=\value{multicitetotal}}
{\setunit{}%
\printtext{%
\ifbool{cbx:parens}
{\bibclosebracket\global\boolfalse{cbx:parens}}
{}}}
{\setunit{%
\ifbool{cbx:parens}
{\bibclosebracket\global\boolfalse{cbx:parens}}
{}%
\textcitedelim}}}

\begin{document}

\autocite{wu2017,wu2018}

\autocite{wu2017,wu2019method}

\autocite{zhu2015,lorenzen2016,manjure2001}

\end{document}


• Thanks for the answer. How to replace the comma between citations with a semicolon? – Al-Motasem Aldaoudeyeh Jun 7 '19 at 2:11
• @Al-MotasemAldaoudeyeh, just add \renewcommand*{\textcitedelim}{\addsemicolon\space} – David Purton Jun 7 '19 at 2:18
• @Al-MotasemAldaoudeyeh, there is also \compcitedelim which controls the delimeter between years when they are compressed. – David Purton Jun 7 '19 at 2:20
• Thanks. This pretty much addresses everything, but \textcite is unusual. I may need to switch citation styles without having to substitute every instant of \cite command. The two styles do not seem to be different with authoryear and authoryear-comp. Is there a way to patch \textcite as above then redefine \cite to behave exactly as \textcite? That way, I will get what I want without having to replace texts with long documents. – Al-Motasem Aldaoudeyeh Jun 7 '19 at 2:42
• @Al-MotasemAldaoudeyeh, see my update. You could switch to using \autocite and point \autocite to \textcite. This can then be easily changed globally. – David Purton Jun 7 '19 at 2:53