0

I have to pass different strings from latex to lua as arguments. I have a solution for an argument in a command, but in case of pgf keys, it seems not working. Use \string is not suitable, if it looks like in this answer lua code inside directlua throws an invalid escape sequence error, because it's not user friendly in pgfkeys argument

Any idea to avoid this problem

\documentclass{beamer}

\newcommand{\Contraintes}[1]{%
    \directlua{ contraintes = "\unexpanded{#1}" }
}


\begin{document}

\pgfkeys{/Baq/.cd ,
            contraintes/.store in = \contraintes,
            contraintes = { 3 ~= 1 }
}

\begin{frame}

% this is working
%\Contraintes{ 2~=1 }


% alternatively this is not working
\directlua{
    contraintes = "\unexpanded{\contraintes}"
}

\directlua{
    tex.print ( contraintes )
}


\end{frame}
\end{document}
2
  • \unexpanded\expandafter{\contraintes}" Commented Jul 7, 2022 at 20:38
  • Works fine, thank you.
    – Tarass
    Commented Jul 8, 2022 at 0:57

1 Answer 1

1

You can use

\unexpanded\expandafter{\contraintes}

or perhaps better

\detokenize\expandafter{\contraintes}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .