7

I want to be able to output nicely formatted math code. So I decided to learn latex and maxima (and use all that in org-mode).

That's when I came across this tutorial http://maxima.sourceforge.net/contrib/maxiplot/maxiplot_en.pdf.

And there, I found this program in section 3.2.1:

\usepackage{amsmath}
\usepackage[amsmath]{maxiplot}
\[   %Math mode begin
\begin{maxima}
f: x/(x^3-3*x+2),     /* Integrating it */
tex('integrate(f,x)), /* will show its integral... */
print("="),
tex(integrate(f,x)),  /* ...and the result */
print("+K")
\end{maxima}
\]   %Math mode end

I tried to execute it, in an org-buffer, by pressing C-c C-x \. But I see no results. The polynomial f: x/(x^3-3*x+2) gets pretty-printed and that's all. But there's not output like anything in the PDF file; a nice integral and so on.

I tried C-c C-x C-l too and the image is blank.

Can anyone tell me, how do I show the output of this latex/maxima program in the org-buffer?

3
  • 1
    I think Org only renders simple LaTeX inline. If this is correct, then for complicated LaTeX fragments that depend on external packages, you need to export to LaTeX and then compile to PDF.
    – mankoff
    Aug 3, 2015 at 1:57
  • 1
    I guess you're trying to actually execute the code, so LaTeX must be able to run maxima. Try exporting to pdf and running pdflatex manually with --shell-escape option (it might be named --enable-write18 or something like that). An alternative way might be to put maxima code as a maxima babel block instead, I think (but not sure...) you can ask org to use the result in the latex export.
    – YoungFrog
    Aug 3, 2015 at 5:41
  • 1
    Here's how I embed Maxima code in Org: github.com/wvxvw/uni-infinitesimal-calculus/blob/… (my calculus assignment...) you'd also need this patch: emacs.stackexchange.com/questions/12402/…
    – wvxvw
    Aug 3, 2015 at 6:41

1 Answer 1

8

\usepackage commands go in the latex preamble, not the document body. You can add these commands with:

#+LATEX_HEADER_EXTRA: \usepackage...

Then you would add your LaTeX code inside of:

#+BEGIN_LATEX
\begin{maxima}
f: x/(x^3-3*x+2),     /* Integrating it */
tex('integrate(f,x)), /* will show its integral... */
print("="),
tex(integrate(f,x)),  /* ...and the result */
print("+K")
\end{maxima}
#+END_LATEX

blocks.

The above would only work when exported to PDF, not in Emacs buffers.

EDIT: In more recent versions of Org mode (Org mode 9.0 or later) the syntax for export blocks has been changed: instead of #+BEGIN_LATEX ... #+END_LATEX, you now have to say #+BEGIN_EXPORT latex ... #+END_EXPORT. See https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/etc/ORG-NEWS#n2665 - although note that the line number is going to be obsolete as soon as the next release appears: it might be safer to search for BEGIN_EXPORT on that page instead. Alternatively, you can (and should) take a look at the ORG-NEWS file that is locally available, probably under /usr/share/emacs or /usr/local/share/emacs, assuming you use the Org mode that is distributed with Emacs. If you install your own, you presumably know where and can therefore find the etc/ORG-NEWS file whereever you installed Org mode.

2
  • 1
    #+BEGIN_LATEX produced \begin{latex} in the .tex-file (org 9.0). Maybe that's a new change due to the new treatment of special blocks. Do you have any idea how to fix this?
    – serv-inc
    Aug 27, 2017 at 15:04
  • 2
    seems like it's fixable using #+BEGIN_EXPORT latex, which is the standard completion for <l<kbd>Tab</kbd> (that is an ell).
    – serv-inc
    Aug 27, 2017 at 15:08

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.