Skip to content

Instantly share code, notes, and snippets.

@k16shikano
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k16shikano/ba636b71a6f84e4f02dd to your computer and use it in GitHub Desktop.
Save k16shikano/ba636b71a6f84e4f02dd to your computer and use it in GitHub Desktop.
TeXマクロでオプション引数っぽいやつ
\newtoks\mytok
\def\torikae#1{\global\mytok\expandafter{#1}\futurelet\cs\dotorikae}
\def\dotorikae{\ifx\cs{\iffalse}\fi
\let\next\getoptional
\else
\let\next\relax
\the\mytok
\fi
\next}
\def\getoptional#1{%
\edef\@tempa{\the\mytok}
\global\mytok\expandafter{#1\@tempa}
\the\mytok}
\torikae{ABC}
\torikae{ABC}{DEF}
@k16shikano
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment