I have used org mode embedded LaTeX for a while. The commonly used syntax such as subscripts, fractions and math symbols works well out of the box. All that is needed is to put the LaTeX content between $ signs. The LaTeX formula even shows correctly when the org-mode file is exported to MS Word format (via pandoc).

However, the translation of embedded LaTeX does not seem to work if I import an external package and use the commands therein. Here is an example org file with one set of LaTeX commands, copied from this TeX exchange example:

#+LATEX_HEADER_EXTRA: \usepackage{mathpartir}

\inferrule* [left=Total]
  {\inferrule* [Left=Foo] {\inferrule* [Right=Bar,
      {a \\ a \\\\ bb \\ cc \\ dd}
    \\ ff \\ gg}
    \inferrule* [lab=XX]{uu \\ vv}{ww}}

When previewed with C-c C-x C-l, it shows an incomplete rendering:

enter image description here

instead of the tree it is supposed to display (replicated below).

enter image description here

Note: Thanks to @Ian's comments, I fixed an error in the example and used an environment. But the preview still does not work, nor does the export (via pandoc) to MS Word (same result as in the screenshot). The only thing that works is to export it to PDF (via pandoc). By the way, copying the content to a .tex file (and removing LATEX_HEADER_EXTRA) does show the correct rendering in the exported PDF.

My question is:

How to configure the org-mode file so that the LaTeX fragment involving an external package can be rendered correctly as embedded images?

Note: Ideally, this should produce the same results as regular formulae, so that they can be exported to other document types such as MS Word. And this is Emacs 29, org-mode 9.6.6 under Ubuntu 22.04 LTS.

  • After declaring the header usepackage{mathpartir} you need to declare the environment ```\begin{mathpar} .... \end{mathpar} in which you will enclose your infer rule. Nothing else to configure.
    – Ian
    Commented Nov 13, 2023 at 12:47
  • @Ian Thanks a lot for your help. I added the environment declaration, and updated the question. The figure is correct now in the PDF output, but the embedded LaTeX preview image and exported .docx is still incorrect.
    – tinlyx
    Commented Nov 13, 2023 at 14:01

1 Answer 1


After some search, this seems to be the same problem as described in this answer with a different package and environment.

The steps I had to do are:

  1. Add the LaTeX package mathpartir to 'org-latex-packages-alist in init.el:
(with-eval-after-load 'org
    ; ...
    (add-to-list 'org-latex-packages-alist '("" "mathpartir" t))
  1. Change the latex preview program to imagemagick in init.el
(setq org-preview-latex-default-process 'imagemagick)
  1. install imagemagick in Ubuntu:

    sudo apt install imagemagick

  2. edit the imagemagick policy /etc/ImageMagick-6/policy.xml and change the line

<policy domain="coder" rights="none" pattern="PDF" />


<policy domain="coder" rights="read|write" pattern="PDF" />

Then, after deleting the cached preview png images ltximg/org-ltximg_*, org-mode is able to generate the correct preview image.

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.