Defining command with optional and mandatory arguments
Hi, What is the right way to define a command with both mandatory and optional arguments, e.g: \MyCommand[optional][mandatory] Consider the following MWE: \unexpanded\def\MyCommand[#1]{ \dosingleempty{\doMyCommand[#1]}} \def\doMyCommand[#1][#2]{ \doifsomething{#1}{number 1: #1\par} \doifsomething{#2}{number 2: #2}\blank[big]} \starttext \MyCommand[A][B] \MyCommand[A] \stoptext In last year's versions of ConTeXt the output was number 1: A number 2: B number 1: A In the latest version of ConTeXt the output is number 1: A number 2: B number 2: A Is this behavior intended? How can I make a definition whose behavior does not change in new versions of ConTeXt? Cheers, Christoph
On 5/23/2018 3:39 PM, Christoph Reller wrote:
\unexpanded\def\MyCommand {\dodoubleempty\doMyCommand} \def\doMyCommand[#1][#2]% {\iffirstargument number 1: #1% \par \fi \ifsecondargument number 2: #2% \fi \blank[big]} \starttext \MyCommand[A][B] \MyCommand[A] \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Am 2018-05-23 um 16:01 schrieb Hans Hagen
Also, there’s documentation at http://wiki.contextgarden.net/Commands_with_optional_arguments If there’s something wrong, please fix it yourself or come back to this list ;) Greetlings, Hraban --- https://www.fiee.net http://wiki.contextgarden.net https://www.dreiviertelhaus.de GPG Key ID 1C9B22FD
participants (3)
-
Christoph Reller
-
Hans Hagen
-
Henning Hraban Ramm