ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 30 Sep 2021 16:55:33 +0200Use LaTeX symbols (like \prime) in variableshttps://ask.sagemath.org/question/59203/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$`.Thu, 30 Sep 2021 14:30:26 +0200https://ask.sagemath.org/question/59203/use-latex-symbols-like-prime-in-variables/Answer by cav_rt for <p>So as we know declarations such as <code>theta=var("theta")</code> when output as LaTeX, they're automatically converted to corresponding LaTeX symbols (<code>$\theta$</code> in this case), but it makes me wonder is it possible for us to use more complicated symbols? Like <code>thetaprime=var("\\theta\\prime")</code> (which obviously doesn't work, I've tried), but I would like to achieve something like this, so when I call <code>latex(eq)</code>, all <code>thetaprime</code> variables are converted to <code>$\theta\prime$</code>.</p>
https://ask.sagemath.org/question/59203/use-latex-symbols-like-prime-in-variables/?answer=59204#post-id-59204Try
thetaprime = var("thetaprime", latex_name="\\theta^\\prime")Thu, 30 Sep 2021 15:39:23 +0200https://ask.sagemath.org/question/59203/use-latex-symbols-like-prime-in-variables/?answer=59204#post-id-59204Comment by eric_g for <p>Try</p>
<pre><code>thetaprime = var("thetaprime", latex_name="\\theta^\\prime")
</code></pre>
https://ask.sagemath.org/question/59203/use-latex-symbols-like-prime-in-variables/?comment=59205#post-id-59205An 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")Thu, 30 Sep 2021 16:55:33 +0200https://ask.sagemath.org/question/59203/use-latex-symbols-like-prime-in-variables/?comment=59205#post-id-59205