# Latex rendering and details

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
$$x=\sqrt{b}$$
#+END_SRC


.emacs:

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


Try this in .emacs

(require 'org)
(require 'ox-latex)
(setq org-latex-create-formula-image-program 'dvipng)


and this as an example org file:

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

* Introduction

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


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.
5. You need to require ox-latex.