Skip to content

Instantly share code, notes, and snippets.

@Artem-B
Forked from nikibobi/colab-latex.py
Created September 30, 2019 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Artem-B/2aa3d67c7df1f83c8d6764960c1a7df9 to your computer and use it in GitHub Desktop.
Save Artem-B/2aa3d67c7df1f83c8d6764960c1a7df9 to your computer and use it in GitHub Desktop.
Add LaTeX support to a Colab notebook for SymPy
import sympy
def custom_latex_printer(exp, **options):
from google.colab.output._publish import javascript
url = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/latest.js?config=default"
javascript(url=url)
return sympy.printing.latex(exp, **options)
sympy.init_printing(use_latex="mathjax", latex_printer=custom_latex_printer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment