4

I know this may have been answered before, but the point is these questions seems to be asked by people who have experience with emacs, lisp, and org mode but not for beginner.

So, sorry for such a simple question. But can anyone explain in detail on the steps required to end up producing latex preview on my .org file.

It is super confusing to me when the org-mode document explains things.

http://orgmode.org/manual/Previewing-LaTeX-fragments.html#Previewing-LaTeX-fragments

1) In the above link, it says "You can customize the variables org-format-latex-options and org-format-latex-header to influence some aspects of the preview."

Where and how exactly can I do this. I am so confused. Not sure if I need it though

2) #+STARTUP: latexpreview

Setting this at the top of my file doesn't help to preview latex. I already have dvipng installed on my system (it is Mac)

3) When should I use M-x bla_bla_bla and when should I use commands (C-c C-c etc.) instead? Are these commands just the shortcuts for the long phrase bla-bla-bla?

4) I have also added the following in my .emacs file. (setq org-latex-create-formula-image-program 'dvipng)

5) If I do C-c C-c within the code block, I get the error saying "No org-babel-execute function for latex!". I do have "latex . t" in my .emacs. That is not the reason I guess.

6) For example the following link tells about packages in latex. But where do I put those things? in .org or in .emacs. if so how? http://orgmode.org/worg/org-tutorials/org-latex-preview.html

Following is what I have

#+STARTUP: latexpreview
* COMMENT Testings
\[
e^{i\pi} = -1
\]
#+BEGIN_SRC latex                                                                                                                                                                                                                                                             
\documentclass{article}                                                                                                                                                                                                                                                       

\begin{document}                                                                                                                                                                                                                                                              

\[                                                                                                                                                                                                                                                                            
e^{i\pi} = -1                                                                                                                                                                                                                                                                 
\]                                                                                                                                                                                                                                                                            

\[                                                                                                                                                                                                                                                                            
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}                                                                                                                                                                                                                              
\]                                                                                                                                                                                                                                                                            

\end{document}                                                                                                                                                                                                                                                                

#+END_SRC                                                                                                                                                                                                                                                                     

#+BEGIN_SRC latex                                                                                                                                                                                                                                                             
\begin{equation}                                                                                                                                                                                                                                                              
x=\sqrt{b}                                                                                                                                                                                                                                                                    
\end{equation}                                                                                                                                                                                                                                                                
#+END_SRC 

.emacs:

(require 'org-install)
(org-babel-do-load-languages
 'org-babel-load-languages
 '((python . t) (sh . t) (latex . t))
 )
(setq org-latex-create-formula-image-program 'dvipng)

1 Answer 1

3

Try this in .emacs

(require 'org)
(require 'ox-latex)
(setq org-latex-create-formula-image-program 'dvipng)
(org-babel-do-load-languages 'org-babel-load-languages '((latex . t)))

and this as an example org file:

#+TITLE: Org latex example
#+STARTUP: latexpreview

* Introduction

Here is an equation:
\[
e^{i\pi} = -1
\]

Some answers to your questions:

  1. You set those variables in your .emacs file using either code you write or the customization interface.
  2. There is a bug in recent org mode releases, so this appears to be currently broken. Type C-c C-x C-l with your cursor over the latex code to see the image.
  3. Personal preference. If you can remember the keybindings, it's less typing (but more work to memorize).
  4. That is correct.
  5. You need to require ox-latex.
  6. You can load latex packages either from your org file if you only want them for that file, or always by setting up some variables in your .emacs.
1
  • Doesn't work :(((((((
    – gogo
    Commented Mar 25, 2016 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.