0

I use org-beamer-export-to-latex to export the current org file to latex. When I try to manually compile the resulting tex file using

latexmk -f -pdf -pdflatex -shell-escape -interaction=nonstopmode x.tex

I get this error:

! LaTeX Error: Environment org undefined.

I think this is because there is a

\begin{org}

in the tex file.

This env seems to be inserted because of this snippet in org-mode:

#+begin_src mermaid :eval no-export :background-color transparent :wrap "org \n#+ATTR_HTML: :width 950 \n#+ATTR_LATEX: :width \\textwidth" :scale 3 :file test..nogit..pdf
graph LR
    A[Image of Bird] -->|Input To| B[Neural Network]
    B -->|Classifies As| C["Bird"]
    E[Attribution Map] -->|Major Contributors Are| D[Pixels Showing Face, Tail, …] 
    B --> E
    C --> E
#+end_src

#+results: 
#+begin_org
#+attr_html: :width 950
#+attr_latex: :width \textwidth
[[file:test..nogit..pdf]]
#+end_org

I am currently using \newenvironment{org}{}{} as a workaround.

1 Answer 1

1

Having :wrap org in the header will wrap the results in a #+begin_org...#+end_org block and the latex exporter will translate that to \begin{org}... \end{org.

Try this instead:

#+name: mygraph
#+begin_src mermaid :eval no-export :background-color transparent :scale 3 :file test..nogit..pdf
graph LR
    A[Image of Bird] -->|Input To| B[Neural Network]
    B -->|Classifies As| C["Bird"]
    E[Attribution Map] -->|Major Contributors Are| D[Pixels Showing Face, Tail, …] 
    B --> E
    C --> E
#+end_src

#+attr_html: :width 950
#+attr_latex: :width \textwidth
#+results: mygraph
[[file:test..nogit..pdf]]

I presume that you tried the :wrap org for the side effect of inserting the #+ATTR_... declarations, but that is not the way to do that. What you need to do is to give your mermaid source block a name (#+name: mygraph above). Then when you run the source block, it will produce a labeled #+results: block. Then you can add the #+attr_... declarations before the #+results: block. You can then rerun the code block and it will still find the labeled #+results: block to put the result under, even though the #+attr_... declarations separate the source block from the results block.

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.