Re: [NTG-context] prevent gobbling of spaces when omitting optional argument
Am 28.01.2011 um 23:24 schrieb Florian Wobbe: 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). With the last beta this does no longer happen and the space after the missing arguments remains. Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] prevent gobbling of spaces when omitting optional argument
Am 28.01.2011 um 23:24 schrieb Florian Wobbe: 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. % \one, \one[…] and \one[…][…] (no spaces between “[][]” allowed) \def\one {\strictdoifnextoptionalelse\doone\noone} \def\noone{[]} \def\doone[#1]% {\strictdoifnextoptionalelse{\dodoone[#1]}{\nodoone[#1]}} \def\dodoone[#1][#2]% {[#1:#2]} \def\nodoone[#1]% {[#1]} % \two, \two{…} and \two{…} (no spaces between “{}{}” allowed) \def\two {\dodoublegroupempty\dotwo} \def\dotwo#1#2% {\ifsecondargument [#1:#2]% \else\iffirstargument [#1]% \else []% \fi\fi} \starttext \startlines \one text \one[1] text \one[1][2] text \two text \two{1} text \two{1}{2} text \stoplines \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] prevent gobbling of spaces when omitting optional argument
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: \def\citep[#1]% {\strictdoifnextoptionalelse{\docitep[#1]}{\nocitep[#1]}} \def\docitep[#1][#2]% {\strictdoifnextoptionalelse{\dodocitep[#1][#2]}{\nodocitep[#1][#2]}} \def\dodocitep[#1][#2][#3]% {\cite[alternative=authoryears, left={(#1 }, extras={#2}][#3]} \def\nodocitep[#1][#2]% {\cite[alternative=authoryears, extras={#1}][#2]} \def\nocitep[#1]% {\cite[alternative=authoryears][#1]} \setuppublications[state=start,refcommand=authoryear] \setupbibtex[database=sample] \starttext \startlines %\cite[hh2010a] % commenting this out does not work \stoplines \citep[, p.\ 1][hh2010a].\par \citep[, p.\ 1][hh2010a] more text.\par \citep[see][, p.\ 1][hh2010a].\par \citep[see][][hh2010a] more text.\par \startlines \cite[hh2010a] % this is ok at the end \stoplines \stoptext I noticed there is this error: using the first cite in \startlines...\stoplines does not work. Florian ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] prevent gobbling of spaces when omitting optional argument
% \one, \one[…] and \one[…][…] (no spaces between “[][]” allowed) \def\one {\strictdoifnextoptionalelse\doone\noone} \def\noone{[]} \def\doone[#1]% {\strictdoifnextoptionalelse{\dodoone[#1]}{\nodoone[#1]}} \def\dodoone[#1][#2]% {[#1:#2]} \def\nodoone[#1]% {[#1]} One more problem: Adding \setupinteraction[state=start] \starttext and\footnote{\one[1]} etc. do not work. Why not? Florian \startlines \one text \one[1] text \one[1][2] text \stoplines \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] prevent gobbling of spaces when omitting optional argument
Hi Florian! On 2011-01-29 17:21:26, Florian Wobbe wrote: % \one, \one[…] and \one[…][…] (no spaces between “[][]” allowed) \def\one \unexpanded\def\one % should make it work in footnotes Philipp {\strictdoifnextoptionalelse\doone\noone} \def\noone{[]} \def\doone[#1]% {\strictdoifnextoptionalelse{\dodoone[#1]}{\nodoone[#1]}} \def\dodoone[#1][#2]% {[#1:#2]} \def\nodoone[#1]% {[#1]} One more problem: Adding \setupinteraction[state=start] \starttext and\footnote{\one[1]} etc. do not work. Why not? Florian \startlines \one text \one[1] text \one[1][2] text \stoplines \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments pgp4M5HUC96WR.pgp Description: PGP signature ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] prevent gobbling of spaces when omitting optional argument
\unexpanded\def\one % should make it work in footnotes Great, that did the trick. Thanks! Florian ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___