Last active
August 29, 2015 14:21
-
-
Save k16shikano/ba636b71a6f84e4f02dd to your computer and use it in GitHub Desktop.
TeXマクロでオプション引数っぽいやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\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} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cf. http://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=1581
完全展開はしない