0

I'm new into latex, org and latex in org so it may sounds like a total newbie question... I want to preview latex in emacs with org-preview-latex-fragment, I have followed instructions from here and trying to preview this code :

#+BEGIN_SRC late :tangle /tmp/example.tex
\documentclass{article}

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

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

\end{document}

#+END_SRC

but it fails with a blank square. I have checked the log in /tmp and latex has an error but I don't know why :

File: ts1cmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions
LaTeX Font Info:    ... okay on input line 33.

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.    
 ...                                              

l.34 \begin{document}

? 
! Emergency stop.
 ...                                              

l.34 \begin{document}

Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.


Here is how much of TeX's memory you used:
 3089 strings out of 493055
 35108 string characters out of 6140611
 80703 words of memory out of 5000000
 6607 multiletter control sequences out of 15000+600000
 4509 words of font info for 16 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 27i,1n,26p,236b,50s stack positions out of                     5000i,500n,10000p,200000b,80000s
No pages of output.

I have tried to compile out of emacs and get the same message, but as it's interactive when I type it works. So why do I get this error and how to make it works within emacs ?

ps: if you need the full log please tell me, it's just that it is huge and doesn't work on my google chrome.

3

Remove the stuff like \documentclass, \begin{document} and \end{document}. This does not belong into an org-document.

Only keep the formulas. The document structure is controlled by org and not by latex.

  • Thank you it was as simple as that. It's a cool feature I love it ! – user3593232 Dec 4 '15 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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