0

My preamble in Jupyter is:

%reset
import numpy as np
from sympy import *
from sympy.physics.quantum import Commutator, Dagger, Operator
from sympy.vector import CoordSys3D
import matplotlib.pyplot as plt
from sympy.interactive import printing
printing.init_printing(use_latex = True)

How do I print the following string in latex form? I crucially do not want the order of the terms within the string to change.

'\\mathbf{R}_B \\cdot j'

2 Answers2

1

So an answer is:

from IPython.display import Math

display(Math('\\mathbf{R}_B \\cdot j'))

Which preserves the order of the symbols. However, 'Math' has no attribute 'subs' and has trouble sympifying, so it seems doing sympy operations on this output isn't possible.

0

Following this solution

from IPython.display import display, Math
display(Math('\\mathbf{R}_B \\cdot j'))

Output

enter image description here

DarrylG
  • 16,732
  • 2
  • 17
  • 23