# org-mode How to use latex nested environments?

I want to use a matrix environment that is included in an outer environment, so:

Environment:
\begin{equation*}
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
\end{equation*}

Display--math:
$\left| \begin{matrix} a_1 & b_1\\ a_2 & b_2 \end{matrix} \right|$

Inline--math:
$$\left| \begin{matrix} a_1 & b_1\\ a_2 & b_2 \end{matrix} \right|$$


But for the second and third cases (display-math and inline-math) the preview and export to latex are failed:

exported LaTeX:

Environment:
\begin{equation*}
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
\end{equation*}

Display--math:
$\backslash$[
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
$\backslash$]

Inline--math:
$\backslash$(
\left|
\begin{matrix}
a_1 & b_1\\
a_2 & b_2
\end{matrix}
\right|
$\backslash$)
\end{document}


org-mode preview:

Emacs 26.3

Org-mode 9.3.8

• I can reproduce it with 9.4 and I believe it is a bug. Please consider submitting a bug report with M-x org-submit-bug-report RET. Sep 20, 2020 at 19:31
• I can reproduce it with Org 9.3 and Emacs 27.1. Having this in an Org buffer produces this LaTeX file by pressing C-c C-e l L. Sep 21, 2020 at 0:20

nested \begin{...} should not start the line and therefore is not seen as starting a new LaTeX block:
Inline-math:
$$\left|\begin{matrix} a_1 & b_1\\ a_2 & b_2 \end{matrix}\right|$$