There are two ways with which you can get LaTeX syntax highlighting when
editing LaTeX in org-mode buffers.
* No. 1: LaTeX code blocks
You can have LaTeX code blocks within your document with the following
header arguments and thus have syntax highlighting and make the content
of those code blocks to be exported as LaTeX.
Advantage: Code blocks are syntax highlighted.
Disadvantage: The code block is not exported when exporting to HTML,
only when exporting to LaTeX.
#+BEGIN_SRC latex :results latex :exports results
\[
\frac{12}{13} + 12
\]
#+END_SRC
* No 2: Executing org-edit-special in LaTeX environments
When using org-edit-special (C-c ') in LaTeX environments, the snippet
is opened in a buffer whose major mode is latex-mode so you get syntax
highlighting within that buffer.
Advantage: The snippets are exported as raw text when exporting to HTML.
Disadvantage: The snippets are not syntax highlighted. They are only syntax
highlighted in the dedicated buffer which is shown in org-edit-special.
#+BEGIN_SRC org
Solving $12 + 13$ is not difficult.
#+END_SRC
#+BEGIN_SRC org
Solving
\[
12 + 13
\]
is not difficult.
#+END_SRC
#+BEGIN_SRC org
Solving
\begin{equation}
12 + 13
\end{equation}
is not difficult.
#+END_SRC
* Side note
If you want to see the behavior when exporting to HTML, I encourage you
to export the following Org Mode file to HTML and see what happens.
#+BEGIN_SRC org
The following is not shown when exporting to HTML.
#+begin_src latex :results latex :exports results
\[
10 + 10
\]
#+end_src
#+RESULTS:
#+begin_export latex
\[
10 + 10
\]
#+end_export
The following is shown as an image when exporting to HTML.
3
#+begin_src latex :exports results :results file graphics :file 20.png
\[
20 + 20
\]
#+end_src
#+RESULTS:
[[file:20.png]]
The following is shown as text when exporting to HTML.
\[
30 + 30
\]
The following is shown as text when exporting to HTML.
\begin{equation}
40 + 40
\end{equation}
#+END_SRC
Hope that helps.
---
Greetings,
rdrg109
On Thu, 24 Jun 2021 at 00:07, Christopher Dimech <
dimech@gmx.com> wrote:
Would it be possible for org-mode to have syntax highlighting
for latex commands? Currently I have to change mode with
"M-x latex-mode" to get the highlighting.