Skip to content

Instantly share code, notes, and snippets.

@rbonvall
Created October 29, 2010 00:20
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 rbonvall/652626 to your computer and use it in GitHub Desktop.
Save rbonvall/652626 to your computer and use it in GitHub Desktop.
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