<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\def\newoptargcommand#1{%
  \@ifnextchar({\@xoptargcmd{#1}}%
               {\newcommand{#1}}%
}
 
\def\@xoptargcmd#1(#2){%
%  \@ifdefinable#1%
%     {
    \expandafter\def\expandafter#1\expandafter{%
          \expandafter
          \@ifnextchar
          \expandafter
          [%
          \csname\string#1\expandafter\endcsname
          \expandafter
          {\csname\string#1\endcsname[#2]}}%
       \expandafter\@zoptargcmd
          \csname\string#1\endcsname
}
 
\def\@zoptargcmd#1{%
  \@ifnextchar[{\@zzoptargcmd#1}%
               {\def#1[####1]}%
}
 
\catcode`\?=11\relax
\long\def\@zzoptargcmd#1[#2]#3{%
  \@tempcnta#2\relax
  \let#1\relax
  \let\@?@\relax
  \edef\@tempa{\long\def#1[\@?@1]}%
  \@tempcntb \tw@
  \@whilenum\@tempcnta&gt;\z@
      \do{%
          \edef\@tempa{\@tempa\@?@\the\@tempcntb}%
          \advance\@tempcntb \@ne
          \advance\@tempcnta \m@ne}%
  \let\@?@##%
  \@tempa{#3}%
}
\catcode`\?=12\relax
\endinput
</pre></body></html>