# How do I get org-mode to treat the output of a non-latex code block as latex?

(Emacs: v27.1, Org: v9.5, pdfTeX: v3.14159265-2.6-1.40.21)

I am using the following Python code block to print LaTeX code:

#+BEGIN_SRC python :session :exports both :results output :wrap math
...
#+END_SRC


That prints:

M^{1} = \left[\begin{matrix}15000.0 \\ 15000.0\end{matrix}\right] \\
...


However, when I export to a LaTeX document, it is interpreted as:

M\textsuperscript{1} = [15000.0 $\backslash$\ 15000.0] \\
...


And that causes the LaTeX compilation to fail. How can I prevent Emacs from reinterpreting the output?

I think you should change :wrap math to :wrap export latex.
That should wrap the output in a #+begin_latex: block, which should in turn export the way you want.
• Wrap just sets the value inside of the \begin{} and \end{} blocks surrounding the output. So :wrap latex does \begin{latex} ... \end{latex} – scrufulufugus Mar 2 at 23:34