[texhax] Undesired blank space

David Carlisle d.p.carlisle at gmail.com
Fri May 4 23:42:34 CEST 2018


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.



On 4 May 2018 at 21:17, Rodolfo Medina <rodolfo.medina at gmail.com> wrote:
> Hi all.
>
> In plain TeX: I wanted to define a command featuring two mandatory arguments
> and two optional:
>
>  \mandoptmandopt#1[#2]#3[#4]
>
> , so I fetched from internet the following stuff:
>
> \long\def\@ifnextchar#1#2#3{%
>   \let\reserved at d=#1%
>   \def\reserved at a{#2}%
>   \def\reserved at b{#3}%
>   \futurelet\@let at token\@ifnch}
> \def\@ifnch{%
>   \ifx\@let at token\@sptoken
>     \let\reserved at c\@xifnch
>   \else
>     \ifx\@let at token\reserved at d
>       \let\reserved at c\reserved at a
>     \else
>       \let\reserved at c\reserved at b
>     \fi
>   \fi
>   \reserved at c}
> \def\:{\let\@sptoken= } \:  % this makes \@sptoken a space token
> \def\:{\@xifnch} \expandafter\def\: {\futurelet\@let at token\@ifnch}
>
> , then did:
>
> \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}[]}
> }
>
> then finally:
>
> \def\mandoptmandopt#1{%
>   \@ifnextchar[%]
>   {\mandoptmandopt@@{#1}}
>   {\mandoptmandopt@{#1}}
> }
>
> Everything seems all right except that...
>
> \mandoptmandopt{John}[Mary]{Alfred}.
>
> I get an undesired blank space before the period.  Why does this happen, and
> how to eliminate it?
>
> Thanks for any help...
>
> Rodolfo
>
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
>
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org


More information about the texhax mailing list