Yet another solution for when you want to have control over the document preamble. Write a whole document, send it to system latex, convert the pdf to png, use IPython.display
to load and display.
import tempfile
import os.path
import subprocess
from IPython.display import Image, display
with tempfile.TemporaryDirectory(prefix="texinpy_") as tmpdir:
path = os.path.join(tmpdir, "document.tex")
with open(path, 'w') as fp:
fp.write(r"""
\documentclass[12pt]{standalone}
\begin{document}
\LaTeX{}
\end{document}
""")
subprocess.run(["lualatex", path], cwd=tmpdir)
subprocess.run(["pdftocairo", "-singlefile", "-transp", "-r", "100", "-png", "document.pdf", "document"], cwd=tmpdir)
im = Image(filename=os.path.join(tmpdir, "document.png"))
display(im)