3
$\begingroup$

TeXForm can be used to convert Mathematica expressions directly to LaTeX. However, this function fails on an expression that has a sub- and a super-script:

expr = Subsuperscript[A, a, b]
expr // TeXForm

enter image description here

My question is:

Is there an alternative Mathematica construct that would translate the above input to A_{a}^{b} under TeXForm operation?

$\endgroup$
3
  • 1
    $\begingroup$ I would report this to Wolfram. $\endgroup$
    – Szabolcs
    Oct 2 '19 at 16:17
  • $\begingroup$ @Szabolcs I sent them an email about it. Any hints for a workaround? $\endgroup$
    – Kagaratsch
    Oct 2 '19 at 16:32
  • 1
    $\begingroup$ I found this page that uses a python script for a workaround: lieret.net/2018/01/04/mathematica-latex-bugs $\endgroup$
    – Jason B.
    Oct 2 '19 at 16:33
6
$\begingroup$

The short answer is to change the default of the following internal variable to False:

BoxForm`$UseTemplateBoxForSubsuperscript = False;

Then:

ToString[Subsuperscript[A, a, b], TeXForm]

"A_a^b"

Another possibility is to teach TeXForm about "Subsuperscript" TemplateBox objects.

$\endgroup$

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.