[texhax] Optional arguments in plain TeX (was: Undesired blank space)

Rodolfo Medina rodolfo.medina at gmail.com
Sun May 6 22:31:05 CEST 2018


David Carlisle <d.p.carlisle at gmail.com> writes:

> if there is no fourth argument you are calling \ma at ndoptmandopt@@@
> supplying [] as fourth argument
> but the definition is
>
> \def\mandoptmandopt@@@#1[#2]#3[#4]{#1 #2 #3 #4}
>
> so #4 may be empty but you are adding a space before it.


Yes...  In order to eliminate those unwanted spaces, I then did so:


\def\mandoptmandopt@@@#1[#2]#3[#4]{%
#1 #2 #3 #4%
}
%%
\def\mandoptmandopt@@@@#1[#2]#3[#4]{%
#1#2 #3 #4%
}
%%
\def\mandoptmandopt@@@@@#1[#2]#3[#4]{%
#1 #2 #3#4%
}
%%
\def\mandoptmandopt@@@@@@#1[#2]#3[#4]{%
#1#2 #3#4%
}
%%
\def\mandoptmandopt@#1#2{%
  \@ifnextchar[%]
    {\mandoptmandopt@@@@{#1}[]{#2}}
    {\mandoptmandopt@@@@@@{#1}[]{#2}[]}
}
%%
\def\mandoptmandopt@@#1[#2]#3{%
  \@ifnextchar[%]
    {\mandoptmandopt@@@{#1}[#2]{#3}}
    {\mandoptmandopt@@@@@{#1}[#2]{#3}[]}
}
%%
\def\mandoptmandopt#1{%
  \@ifnextchar[%]
  {\mandoptmandopt@@{#1}}
  {\mandoptmandopt@{#1}}
}
%%

It seems to work...

Thanks,

Rodolfo



More information about the texhax mailing list