MATLAB: Symbolic toolbox: printing greek letters using latex() function

latexsymbolic

I use latex() function to print results of symbolic calculations and then paste results into a latex code. How do I make MatLab to add backslash in front of greek letters? Example:
syms xi a alpha
f = xi+a^alpha
latex(f)
This code produces output:
\mathrm{xi} + a^{\mathrm{alpha}}
What I want is to get a formula ready to paste into latex code (with backslashes in front of greek symbols):
\mathrm{\xi} + a^{\mathrm{\alpha}}
If it is not possible to do using Matlab, maybe there are other simple ways to automate the process of adding backslashes?
Thanks!

Best Answer

regexprep(f, '(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)', '\\$1', 'preservecase')