Skip to content

Instantly share code, notes, and snippets.

@efraintorlo
Last active October 8, 2016 05:26
Show Gist options
  • Save efraintorlo/a2e1f55b7237c0263a48f282ac366e44 to your computer and use it in GitHub Desktop.
Save efraintorlo/a2e1f55b7237c0263a48f282ac366e44 to your computer and use it in GitHub Desktop.
Clean the LaTeX output for functions and expressions in SageMathCloud. This can be used to dump latex in files or for show clean latex outputs inside sagews notebooks.
import re
def latex_clean(f):
_latex = re.sub('\\\\left\([{}\w\s\\\\,]+\s\\\\right\)\s\\\\\s\{\\\\mapsto\}\s\\\\\s', '', f._latex_())
return _latex
def show_clean(f):
_latex = r"$" + latex_clean(f) + "$"
show(_latex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment