I modified your sample code a bit to make emacs understand how much of this needs to be replaced with latex fragments:
def proj_levenberg(x,y,wsqrt,A): """ Finds a homography between two sets of 2d points. Specifically, approximately minimize the weighted image plane error \(min_A sum_{X,y,w} w ||(A_12 x_) / (A_3 x_1) - y||^2\) where \(x_1\)=[x;1], \(A_{12}\) are the first two rows of A and \(A_3\) is the third row of A. """
Please note that I wrapped the latex fragments between \( and \) Source
You need to set org mode. Org is installed by default in emacs, but I have the latest org mode (version 8.0+) installed using the emacs package manager.
I have the following in my emacs setup for previewing latex fragments:
;; Previewing latex fragments in org mode (setq org-latex-create-formula-image-program 'imagemagick) ;; Recommended to use imagemagick (load "auctex.el" nil tt) (load "preview-latex.el" nil tt) (setq LaTeX-command "latex -shell-escape")
My org mode setting for emacs
My latex installation for emacs
With this setting, when I do Mx org-preview-latex-fragment , I get the following. You can remove the previews with Mx org-ctrl-c-ctrl-c Note that I do not need the main mode to be org-mode . This function worked even where the buffer was in Python mode and the file was temp.py.
The trick is that this function should be run every time you reopen this file; emacs does not save the preview state of each file.

source share