I love that I can insert raw LaTeX fragments in my Org files, and the HTML exporter handles them automatically (either leaving them for MathJax to display, or processing them to images).

I'm working on a file where I want to wrap my fragments in src blocks—#+BEGIN_SRC latex / #+END_SRC—mainly for ease of tangling them all together. Unfortunately, the HTML exporter—after processing these to #+BEGIN_LaTeX / #+END_LaTeX—now skips right over them.

I realize this is by design, per the manual on quoted latex code, but I’d like to switch it up for this particular file. Is there a setting I can configure? Alternatively, which function should I advise to get the behavior I want?

2 Answers 2


Is there a setting I can configure?

These headers give me the raw LaTeX code in my html output when I use the normal HTML backend:

#+BEGIN_SRC latex :noweb yes :exports code
Everything in this block prints in HTML when printed with C-c C-e h o


I want the html exporter to process the code the same way it would if I typed it raw into the org file.

If you need to process the latex src block, then use this:

#+BEGIN_SRC latex :file img.png
C-c C-c in this block to see link created below
This png file will then be inserted in your html output
For more control of the output look into imagemagick headers that 
you can add to this src block. See the org-babel manual for details.  
  • Ah, yes, you're right, I get the same result. I need to update the question, because it wasn't clear. I don't want the raw code to appear in the html output ... I want the html exporter to process the code the same way it would if I typed it raw into the org file. A/k/a the exporter should turn the code into an image, or leave it for MathJax to display. Compare what you have in your answer with what you get when you kill just the BEGIN_SRC and END_SRC lines. Apr 29, 2016 at 3:24
  • See the updated response.
    – Emacs User
    Apr 29, 2016 at 5:14
  • TIL latex blocks can take a file argument. Neat Apr 29, 2016 at 6:05

The following works to give a latex-mode editing environment within org-mode but then have it export unprocessed for MathJax to work on:

#+BEGIN_SRC latex :results html replace :exports results :eval t
    x! =
      1 & x = 0 \\
      x * (x-1)! & \text{otherwise} \\

Which results in:

  x! =
    1 & x = 0 \\
    x * (x-1)! & \text{otherwise} \\

Note that the ob-latex feature should be loaded before executing the example above.

  • what is the :results html supposed to do? I can't find anything like that in org documentation.
    – JeanPierre
    Sep 18, 2016 at 11:51
  • Manual page here: html Results are assumed to be HTML and will be enclosed in a BEGIN_HTML block. E.g., :results value html. Sep 20, 2016 at 4:56
  • Unfortunately this still exports as org-src block on HTML. There is something that I can do to just export the raw latex? Without the css thing for org-src blocks. Nov 9, 2017 at 10:47
  • If I try execute that block with C-c C-c I got org-babel-execute-src-block: No org-babel-execute function for latex! Nov 9, 2017 at 10:51
  • I found a solution, we need ensure that ob-latex was load. (require 'ob-latex) solved. Nov 9, 2017 at 11:06

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.