I wish to write full latex code then show result as a image in org mode. My idea is:

  1. Use EXAMPLE block to write full latex code.
  2. Use emacs-lisp to compile the latex code to png.
  3. Show png file but "file:latex.png".

Code as below:

#+NAME: latexcircle
\draw[red] (0,0) circle (1cm);   

#+BEGIN_SRC emacs-lisp :var latexcode=latexcircle
(setq latexfile "tmp.tex")
(write-region latexcode nil latexfile)
(setq latexcmd (format "pdflatex --shell-escape %s" latexfile))
(shell-command-to-string latexcmd)

: file:latex.png

The file latex.png is created successfully but the result doesn't show the image. I try to use "file latex.png but it doesn't work.

1 Answer 1


Refer to this link

#+HEADER: :headers '("\\usepackage{tikz}")
#+BEGIN_SRC latex :fit yes :file latex.png :imagemagick yes :iminoptions -density 600 
\draw[red] (0,0) circle (1cm);

Output: enter image description here


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.