What is the right way to define a macro with an optional argument that can be called within the <postnote> optional argument to biblatex \cite?

The last two \cite below don't work.

(Unless they are enclosed in braces as the third and fourth \cite)

enter image description here

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


@Book{mykey, author={Author}, title={Title}, journal={Journal}, year={1950}}

\newcommand         \x [2][] {\ifthenelse{\equal{#1}{}}{}{(#1)}#2}
\NewDocumentCommand \y {mo}  {#1\IfValueT{#2}{(#2)}}


\cite [\x{100}]      {mykey}

\cite [\y{100}]      {mykey}

\cite [{\x[a]{100}}] {mykey}

\cite [{\y{100}[a]}] {mykey}

\cite [\x[a]{100}]   {mykey}

\cite [\y{100}[a]]   {mykey}

  • 3
    Adding the braces is the right thing to do. {} matching is built in to the TeX parser (that is matching characters of catcode 1 and 2) LaTeX [] options are parsed with a delimited macro so they end at the first ] without counting nested []. So you need the {} to hide the inner square bracket. Commented Jan 23, 2013 at 23:31
  • @DavidCarlisle That's true for commands defined using the standard LaTeX method (which is what biblatex does), but not those using xparse, which does deal correctly with the nesting here.
    – Joseph Wright
    Commented Jan 24, 2013 at 15:25

1 Answer 1


The postnote formatting directive already acts on the contents of the postnote field. Its default definition can be found in biblatex.def:


Passing macros like \x{100} to the postnote argument prevents biblatex from recognizing page references. So you should modify the directive instead. The example below takes this approach. Postnotes can be specified in the form:

\cite[<prenote>][(<postnote prefix>)(<postnote suffix>)<postnote stem>]{<key>}

where the postnote prefix and suffix arguments are optional. When only one is given it is assumed to be a suffix. New directives are used to format each of the three postnote parts.


% just for demonstration








\subsection*{Without postnote affixes}
\cite[See][11--19 and the last section]{companion}
\subsection*{With postnote affixes}
\cite[See][(pre)(post)11--19 and the last section]{companion}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .