Skip to content

Instantly share code, notes, and snippets.

@dandrake
Last active June 13, 2019 08:47
Show Gist options
  • Save dandrake/6d7e46f36cecab6d89bc to your computer and use it in GitHub Desktop.
Save dandrake/6d7e46f36cecab6d89bc to your computer and use it in GitHub Desktop.
Use MMM for SageTeX in emacs
;; add this to your .emacs / init.el to use mmm (multiple major modes) with SageTeX. This works with AUCTeX and
;; emacs 23.4. The fontification gets a little wonky, though; quotes inside a SageTeX environment throw
;; off the highlighting for the LaTeX bits that follow. But the modes correctly get switched.
;; if you don't have sage-mode installed, you can either (1) do "sage -i sage-mode" and follow the instructions to
;; enable it, or (2) replace sage-mode below with python-mode, which is good enough for regular editing of Sage code
(require 'mmm-auto)
(setq mmm-global-mode 'maybe)
(mmm-add-classes
'((sagetex
:submode sage-mode
:delimiter-mode nil
:front "\\\\begin{sage\\(block\\|silent\\|verbatim\\|example\\|commandline\\)}"
:back "\\\\end{sage~1}"
:save-matches 1)))
(mmm-add-mode-ext-class nil "\\.tex\\'" 'sagetex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment