Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sphinx extension for mapping unicode symbols to their LaTeX equivalents
# encoding: utf-8
import sphinx.util.texescape as te
replacements = ur'''
✓ OK
✗ XX
\ensuremath{^{0}}
¹ \ensuremath{^{1}}
² \ensuremath{^{2}}
³ \ensuremath{^{3}}
\ensuremath{_{0}}
\ensuremath{_{1}}
\ensuremath{_{2}}
\ensuremath{_{3}}
\ensuremath{\heartsuit}
\ensuremath{\clubsuit}
\ensuremath{\diamondsuit}
\ensuremath{\spadesuit}
+
+
+
+
+
+
\textbar{}
─ -
Δ D
± \ensuremath{\pm}
\ensuremath{-}
\ensuremath{\lceil}
\ensuremath{\rceil}
\ensuremath{\lfloor}
\ensuremath{\rfloor}
'''
def setup(app):
replacement_list = [
tuple(line.strip().split())
for line in replacements.strip().splitlines()
]
te.tex_replacements += replacement_list
te.init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.