emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rodrigo Morales <moralesrodrigo1100@gmail.com>
To: Christopher Dimech <dimech@gmx.com>
Cc: Help Emacs Orgmode <emacs-orgmode@gnu.org>
Subject: Re: Latex highlighting for org-mode
Date: Thu, 24 Jun 2021 11:28:08 -0500	[thread overview]
Message-ID: <CAGxMbPbeEp=7Ecui9A6PtznRgT74hSVWeVqesrNt66f5SF6s2g@mail.gmail.com> (raw)
In-Reply-To: <trinity-c4b424fc-aa7c-462e-ada4-b31caccc3067-1624511231488@3c-app-mailcom-bs14>

[-- Attachment #1: Type: text/plain, Size: 2269 bytes --]

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.
>
>
>

[-- Attachment #2: Type: text/html, Size: 2896 bytes --]

  reply	other threads:[~2021-06-24 16:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24  5:07 Latex highlighting for org-mode Christopher Dimech
2021-06-24 16:28 ` Rodrigo Morales [this message]
2021-06-24 17:25   ` Christopher Dimech
2021-06-24 17:30     ` Eric S Fraga
2021-06-24 17:43       ` Christopher Dimech
2021-06-24 17:54         ` Rob Sargent
2021-06-24 18:09           ` Christopher Dimech

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGxMbPbeEp=7Ecui9A6PtznRgT74hSVWeVqesrNt66f5SF6s2g@mail.gmail.com' \
    --to=moralesrodrigo1100@gmail.com \
    --cc=dimech@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).