Skip to content

Instantly share code, notes, and snippets.

@cefstat
Created November 14, 2008 10:44
Show Gist options
  • Save cefstat/24857 to your computer and use it in GitHub Desktop.
Save cefstat/24857 to your computer and use it in GitHub Desktop.
Show a few TeX math commands with the corresponding Unicode symbol in Emacs
;; Fancy stuff
(setq cefstat/fancy-TeX-pairs
'(("le" . ?≤)
("ge" . ?≥)
("infty" . ?∞)
("times" . ?⨯)
("in" . ?∈)
("ni" . ?∋)
("wedge" . ?∧)
("partial" . ?∂)
("int" . ?∫)
("oint" . ?∮)
("nabla" . ?∇)
("to" . ?→)
("rightarrow" . ?→)
("mapsto" . ?↦)
("cup" . ?∪)
("cap" . ?∩)
("subset" . ?⊂)
("subseteq" . ?⊆)
("supset" . ?⊃)
("supseteq" . ?⊇)
("pm" . ?±)
("mp" . ?∓)
("setminus" . ?∖)
("gg" . ?≫)
("ll" . ?≪)
("approx" . ?≈)
("hbar" . ?ℏ)
("ell" . ?ℓ)
;; greek
("alpha" . ?α)
("beta" . ?β)
("Beta" . ?Β)
("gamma" . ?γ)
("Gamma" . ?Γ)
("delta" . ?δ)
("Delta" . ?Δ)
("epsilon" . ?ϵ)
("varepsilon" . ?ε)
("zeta" . ?ζ)
("eta" . ?η)
("theta" . ?θ)
("Theta" . ?Θ)
("vartheta" . ?ϑ)
("iota" . ?ι)
("kappa" . ?κ)
("lambda" . ?λ)
("Lambda" . ?Λ)
("mu" . ?μ)
("nu" . ?ν)
("xi" . ?ξ)
("Xi" . ?Ξ)
("omicron" . ?ο)
("pi" . ?π)
("Pi" . ?Π)
("varpi" . ?ϖ)
("rho" . ?ρ)
("sigma" . ?σ)
("Sigma" . ?Σ)
("varsigma" . ?ς)
("tau" . ?τ)
("upsilon" . ?υ)
("phi" . ?φ)
("Phi" . ?Φ)
("varphi" . ?ϕ)
("chi" . ?χ)
("psi" . ?ψ)
("Psi" . ?Ψ)
("omega" . ?ω)
("Omega" . ?Ω)
))
(setq cefstat/fancy-TeX-pairs-bold
'(("R" . ?R)
("Z" . ?Z)
("Q" . ?Q)
("S" . ?S)
("T" . ?T)
("N" . ?T)
("setR" . ?R)
("setZ" . ?Z)
("setQ" . ?Q)
("setS" . ?S)
("setT" . ?T)
("setN" . ?T)
("dd" . ?d)
("ii" . ?i)
))
(defun cefstat/fancy-TeX ()
(progn
(dolist (p cefstat/fancy-TeX-pairs)
(font-lock-add-keywords
nil `((,(concat "\\(\\\\" (car p) "\\)[^a-zA-Z]")
(1 (progn (compose-region (match-beginning 1) (match-end 1) ,(cdr p))
nil))))))
(dolist (p cefstat/fancy-TeX-pairs-bold)
(font-lock-add-keywords
nil `((,(concat "\\(\\\\" (car p) "\\)[^a-zA-Z]")
(1 (progn (compose-region (match-beginning 1) (match-end 1) ,(cdr p))
nil))
(1 'font-latex-bold-face t)))))))
(add-hook 'LaTeX-mode-hook 'cefstat/fancy-TeX)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment