1

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?

1

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
\begin{test}
Everything in this block prints in HTML when printed with C-c C-e h o
\end{test}
#+END_SRC

UPDATE:

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
\begin{figure}
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.  
\end{figure}
#+END_SRC
  • 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. – purple_arrows Apr 29 '16 at 3:24
  • See the updated response. – Emacs User Apr 29 '16 at 5:14
  • TIL latex blocks can take a file argument. Neat – purple_arrows Apr 29 '16 at 6:05
0

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
  \begin{equation}
    x! =
    \begin{cases}
      1 & x = 0 \\
      x * (x-1)! & \text{otherwise} \\
    \end{cases}
  \end{equation}
#+END_SRC

Which results in:

#+RESULTS:
#+BEGIN_HTML
\begin{equation}
  x! =
  \begin{cases}
    1 & x = 0 \\
    x * (x-1)! & \text{otherwise} \\
  \end{cases}
\end{equation}
#+END_HTML

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 '16 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. – Andrea Reina Sep 20 '16 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. – Manoel Vilela Nov 9 '17 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! – Manoel Vilela Nov 9 '17 at 10:51
  • I found a solution, we need ensure that ob-latex was load. (require 'ob-latex) solved. – Manoel Vilela Nov 9 '17 at 11:06

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.