4

I was looking for a way to get biblatex's \autocite{} command to change the parentheses from normal parentheses to brackets if issued within a stretch of text enclosed by parentheses, but was unable to find anything either here, or in the biblatex and biblatex-chicago manuals.

Consider this MWE:

% !TEX TS-program = xelatexmk
\documentclass{article}
\usepackage{filecontents}
\usepackage[authordate, backend=biber, parentracker=true, cmsdate=both]{biblatex-chicago}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{test1,
  author = {Antelope, Alfred},
  year = {2010},
  title = {A Title},
  url = {www.url.com},
  urldate = {2015-05-05},  
  journal = {Journal},
  volume = {1},
  number = {2},
  pages = {3--15}
}
@article{test2,
  author = {Bee, Ben},
  year = {2011},
  origyear = {1960},
  title = {Best Title},
  journal = {Journal},
  volume = {1},
  number = {2},
  pages = {3--4}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}

Text (in parenthesis \autocite{test1})

Text (in parenthesis \autocite{test2})

\end{document}

It gives me:

Text (in parenthesis (Antelope 2010))
Text (in parenthesis (Bee [1960] 2011))

but I was hoping for

Text (in parenthesis [Antelope 2010])
Text (in parenthesis [Bee (1960) 2011])

I originally thought that parentracker=true would take care of that automatically, but it seems to be there for a different purpose?

jan
  • 2,236

1 Answers1

3

biblatex can only track brackets/parentheses that were set using its commands, literal ( and ) are not tracked.

Use \parentext (or \mkbibparens) instead of literal ( and ).

Text \parentext{in parenthesis \autocite{test1}}

Text \parentext{in parenthesis \autocite{test2}}

gives

Text (in parenthesis [Antelope 2010])

Text (in parenthesis [Bee (1960)2011])

See also How to get an option for square brackets in \textcite?


You could also make ( and ) active so that they automatically use biblatex's \bibopenparen and \bibcloseparen. That can cause some really bad trouble though since it makes ( and ) active characters.

I would advise against making ( and ) active.

MWE

\documentclass{article}
\usepackage[authordate, backend=biber, parentracker=true, cmsdate=both]{biblatex-chicago}
\addbibresource{biblatex-examples.bib}

\catcode(=\active \catcode)=\active \def({\bibopenparen} \def){\bibclosebracket}

\begin{document} Text (in parenthesis \autocite{sigfridsson})

Text (in parenthesis \autocite{kullback:reprint}) \end{document}

moewe
  • 175,683
  • Thanks a lot! One quick follow up: what is the difference between \mkbibparens and \parentext if there is one? – jan Nov 29 '16 at 15:53
  • 3
    @jan In biblates.sty we have \newrobustcmd*{\parentext}{\mkbibparens}. From what I could find in the documentation, I'm lead to believe that \parentext is the higher-level command, so I suggest you use that. – moewe Nov 29 '16 at 17:01
  • I had another idea: Would it be terribly wrong or dangerous to define \let\(=\bibopenparen and \let\)=\bibclosebracket and then use \( and \) where needed? Works with the MWE but I want to make sure that I won't break anything elsewhere ... – jan Nov 29 '16 at 17:33
  • @jan Mhh, \( starts math mode (in LaTeX not TeX, so you can write \(a\) instead of $a$). So it might not be the best idea to overwrite that... – moewe Nov 29 '16 at 17:39
  • Oh, I see. Maybe I can use \< and \> then. A search didn't bring up anything meaningful for these. – jan Nov 29 '16 at 17:51