Ask Your Question
1

Use LaTeX symbols (like \prime) in variables

asked 3 years ago

andrewyg gravatar image

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$.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 3 years ago

cav_rt gravatar image

Try

thetaprime = var("thetaprime", latex_name="\\theta^\\prime")
Preview: (hide)
link

Comments

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")
eric_g gravatar imageeric_g ( 3 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 3 years ago

Seen: 966 times

Last updated: Sep 30 '21