I want to print Latex Code with a Lua Function. But there is a problem with my function if there are parenthesis in the string: in the example the second code will not be printed), who can help me?

\setdefaultlanguage[spelling=new, babelshorthands=true]{german}

function myprint(string)

\newcommand*{\myprint}[1]{\directlua{myprint([[#1]])} }

\myprint{works fine $\pi\cdot x^2$}
\myprint{doesn't work $\sqrt{2}$}

Ok, i have found a working solution with xparse package:


and then using


The v means verbatim, that makes it work!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.