# Use LaTeX symbols (like \prime) in variables

So as we know declarations such as theta=var("theta") when output as LaTeX, they're automatically converted to corresponding LaTeX symbols ($\theta$ in this case), but it makes me wonder is it possible for us to use more complicated symbols? Like thetaprime=var("\\theta\\prime") (which obviously doesn't work, I've tried), but I would like to achieve something like this, so when I call latex(eq), all thetaprime variables are converted to $\theta\prime$.

edit retag close merge delete

Sort by » oldest newest most voted

Try

thetaprime = var("thetaprime", latex_name="\\theta^\\prime")

more

5

An alternative, avoiding the use of repeated backslashes, is to prefix the latex string with r, for "raw", so that each backslash is interpreted as an ordinary character to be passed to LaTeX:

thetaprime = var("thetaprime", latex_name=r"\theta\prime")

( 2021-09-30 16:55:33 +0100 )edit