[NTG-context] prevent gobbling of spaces when omitting optional argument

Florian Wobbe Florian.Wobbe at awi.de
Sat Jan 29 15:57:12 CET 2011

>> Hi,
>> please consider the following minimal example:
>> \def\before{\dodoubleempty\dobefore}%
>> \def\dobefore[#1][#2]{before}
>> \starttext
>> \before[] after (should be: \before[]\ after without explicit \type{\ })\par
>> \before[]after\par
>> \before[][] after\par % this works
>> \before[][]after\par
>> \stoptext
>> How can I prevent gobbling the following space, when the second optional argument is not given (i.e. first line). The macro itself should not insert space if the command is followed by any other character (2nd and 4th line).
> What do you want to achieve, maybe there is already something available.

Wolfgang, thank you very much! Recursion is really an elegant way. I wanted a wrapper around \cite with the same functionality like natbib's \citep[][]{} and \citet[][]{}, which saves a lot of typing. Especially if you start writing a text and at a later point decide to have a citation in parenthesis instead of textual. And of cause, if you switch between both styles in the same text.

Following your example, I came up with this now:



 {\cite[alternative=authoryears, left={(#1 }, extras={#2}][#3]}

 {\cite[alternative=authoryears, extras={#1}][#2]}



%\cite[hh2010a] % commenting this out does not work
\citep[, p.\ 1][hh2010a].\par
\citep[, p.\ 1][hh2010a] more text.\par
\citep[see][, p.\ 1][hh2010a].\par
\citep[see][][hh2010a] more text.\par
\cite[hh2010a] % this is ok at the end

I noticed there is this error: using the first cite in \startlines...\stoplines does not work.


More information about the ntg-context mailing list