2

Is it impossible to covert string back into macro? I know that with lualatex we can do a lot of funny things with macros. I have never seen string converting without it.

\documentclass{article}                                  
\usepackage[utf8]{inputenc}                              
\usepackage[T1]{fontenc}                                 
\usepackage{tikz}                                        

\newcommand{\dosthfunny}{\foreach \x in {1,...,5} {\x\\}}

\def\Macro{\dosthfunny}                                  

\makeatletter                                            
\edef\String{\expandafter\strip@prefix\meaning\Macro}    
\makeatother                                             

\begin{document}                                         
\String %change it to \dosthfunny macro                                                 
\end{document}                                           

1 Answers1

1

It's not very clear what's the reason for this indirect method. You can use \scantokens:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\newcommand{\dosthfunny}{\foreach \x in {1,...,5} {\x\\}}

\def\Macro{\dosthfunny}

\makeatletter
\edef\String{\expandafter\strip@prefix\meaning\Macro}
\makeatother

\begin{document}

\noindent
\scantokens\expandafter{\String} %change it to \dosthfunny macro

\end{document}

enter image description here

egreg
  • 1,121,712