5

I want to be able to output nicely formated 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 foudn 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 execte 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 in blank.

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

  • 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 '15 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 '15 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 '15 at 6:41
4

\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.

  • #+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 '17 at 15:04
  • 1
    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 '17 at 15:08

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.