blefloch / latex-unravel

Watching TeX digest tokens
24 stars 1 forks source link

`\scantokens` leaves extra pair of braces #55

Closed muzimuzhi closed 6 months ago

muzimuzhi commented 1 year ago

For definition \edef\x{\scantokens{abc\noexpand}, if wrapped in \unravel, an extra pair of braces is added to the result of \scantokens.

\documentclass{article}
\usepackage{unravel}

\begin{document}
         \edef\x{\scantokens{abc\noexpand}}
\unravel{\edef\y{\scantokens{abc\noexpand}}}

\show\x % macro:->abc
\show\y % macro:->{abc} % WRONG DEFINITION

% another example without \edef
$a          \scantokens{+\noexpand}  b$
$a \unravel{\scantokens{+\noexpand}} b$ % output looks like $a{+}b$
\end{document}
PhelypeOleinik commented 1 year ago

Actually just \unravel{\scantokens{+}} adds the extra braces, and \unravel{\edef\y{\scantokens{abc}}} incorrectly works.

Bruno fixed \scantokens at the macro level ;-)