Notebook Configuration for Combination of Wolfram Language and LaTeX Formatting for Quantum Mechanic

Dear Wolfram Community,

I’m currently in the process of writing a book on solutions to quantum mechanics problems using the Wolfram Language. Part of my requirement for this project includes setting up my output in LaTeX formatting for mathematical elegance, and keeping my input in Wolfram Language for coding purpose.

To illustrate, consider the following piece of code:

In[20]:= Inner[Times, Array[PauliMatrix, 4, 0], Array[Subscript[a, #] &, 4, 0], Plus, 1]

This outputs:

Out[20]= {{Subscript[a, 0] + Subscript[a, 3], Subscript[a, 1] - I Subscript[a, 2]}, {Subscript[a, 1] + I Subscript[a, 2], Subscript[a, 0] - Subscript[a, 3]}}

I would like for my output to be automatically formatted in LaTeX, while my input remains in the Wolfram language. What would be the optimal way to do such a task? Are there any specific notebook configurations, plug-ins, or packages that would assist in achieving this goal?

I would greatly appreciate any advice you could provide on this note. Creating a seamless blend of both Wolfram and LaTeX within my notebook would undoubtedly enhance the practicality and aesthetics of my upcoming book.

Many thanks for your assistance,

Regards,
Zhao

For simplicity I would recommend TraditionalForm, which is a reasonable approximation to LaTeX.

Otherwise, for hard-core LaTeX within Mathematica take a look at MaTeX.

Otherwise, for hard-core LaTeX within Mathematica take a look at
MaTeX.

  1. Can I install this package just by directly cloning its GitHub repository under ~/.Mathematica/Applications/?
  2. It seems that there are still some bugs about this package, e.g., this one.
  1. Can I install this package just by directly cloning its GitHub
    repository under ~/.Mathematica/Applications/?

I’ve tried and this way works.

  1. It seems that there are still some bugs about this package, e.g., this one.

This bug still exists, but I meet different error messages.

PS: A strange thing: 2. will be displayed as 1., and I don’t know how to fix this issue.

Regards,
Zhao