emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Latex highlighting for org-mode
@ 2021-06-24  5:07 Christopher Dimech
  2021-06-24 16:28 ` Rodrigo Morales
  0 siblings, 1 reply; 7+ messages in thread
From: Christopher Dimech @ 2021-06-24  5:07 UTC (permalink / raw)
  To: Help Emacs Orgmode

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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Latex highlighting for org-mode
  2021-06-24  5:07 Latex highlighting for org-mode Christopher Dimech
@ 2021-06-24 16:28 ` Rodrigo Morales
  2021-06-24 17:25   ` Christopher Dimech
  0 siblings, 1 reply; 7+ messages in thread
From: Rodrigo Morales @ 2021-06-24 16:28 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Emacs Orgmode

[-- 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 --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Latex highlighting for org-mode
  2021-06-24 16:28 ` Rodrigo Morales
@ 2021-06-24 17:25   ` Christopher Dimech
  2021-06-24 17:30     ` Eric S Fraga
  0 siblings, 1 reply; 7+ messages in thread
From: Christopher Dimech @ 2021-06-24 17:25 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: Help Emacs Orgmode

[-- Attachment #1: Type: text/html, Size: 4351 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Latex highlighting for org-mode
  2021-06-24 17:25   ` Christopher Dimech
@ 2021-06-24 17:30     ` Eric S Fraga
  2021-06-24 17:43       ` Christopher Dimech
  0 siblings, 1 reply; 7+ messages in thread
From: Eric S Fraga @ 2021-06-24 17:30 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Emacs Orgmode

On Thursday, 24 Jun 2021 at 19:25, Christopher Dimech wrote:
> I conclude that org-mode cauld do with some improvements.  If org-mode
> was designed to allow LaTeX fragments without the need of any special
> marking, it should allow latex syntex highlighting without the need of
> any special markings.

What you want then is AUCTeX mode?  If you want to write in LaTeX, use a
mode for it.  

Org is about much more than LaTeX and bending it backwards to make it
AUCTeX would be detrimental (see recent discussion on performance issues
with large special blocks).  You can have LaTeX blocks which you can
edit very nicely and the rest of the document's interactive use does not
have to suffer.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-571-gc591be
: Latest paper written in org: https://arxiv.org/abs/2106.05096


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Latex highlighting for org-mode
  2021-06-24 17:30     ` Eric S Fraga
@ 2021-06-24 17:43       ` Christopher Dimech
  2021-06-24 17:54         ` Rob Sargent
  0 siblings, 1 reply; 7+ messages in thread
From: Christopher Dimech @ 2021-06-24 17:43 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: Help Emacs Orgmode


I only proposed colour highlighing for mathematical snippets.  Nothing else.

Or making org able to export to html even when one is using LaTeX blocks.

In that sense, it would act in ways similar to texinfo, using a single
source file to produce output in a number of formats, both online and printed.

> Sent: Friday, June 25, 2021 at 5:30 AM
> From: "Eric S Fraga" <e.fraga@ucl.ac.uk>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "Help Emacs Orgmode" <emacs-orgmode@gnu.org>
> Subject: Re: Latex highlighting for org-mode
>
> On Thursday, 24 Jun 2021 at 19:25, Christopher Dimech wrote:
> > I conclude that org-mode cauld do with some improvements.  If org-mode
> > was designed to allow LaTeX fragments without the need of any special
> > marking, it should allow latex syntex highlighting without the need of
> > any special markings.
>
> What you want then is AUCTeX mode?  If you want to write in LaTeX, use a
> mode for it.
>
> Org is about much more than LaTeX and bending it backwards to make it
> AUCTeX would be detrimental (see recent discussion on performance issues
> with large special blocks).  You can have LaTeX blocks which you can
> edit very nicely and the rest of the document's interactive use does not
> have to suffer.
>
> --
> : Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-571-gc591be
> : Latest paper written in org: https://arxiv.org/abs/2106.05096
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Latex highlighting for org-mode
  2021-06-24 17:43       ` Christopher Dimech
@ 2021-06-24 17:54         ` Rob Sargent
  2021-06-24 18:09           ` Christopher Dimech
  0 siblings, 1 reply; 7+ messages in thread
From: Rob Sargent @ 2021-06-24 17:54 UTC (permalink / raw)
  To: emacs-orgmode

On 6/24/21 11:43 AM, Christopher Dimech wrote:
> I only proposed colour highlighing for mathematical snippets.  Nothing else.
>
> Or making org able to export to html even when one is using LaTeX blocks.
>
> In that sense, it would act in ways similar to texinfo, using a single
> source file to produce output in a number of formats, both online and printed.
>
>
Print and digital are vastly different worlds.  Given that one can plop 
most any file in a web page I would rather see more work on making print 
layout easier without resorting to latex directives or other single 
target mark-ups.  Even at the expense of html output.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Latex highlighting for org-mode
  2021-06-24 17:54         ` Rob Sargent
@ 2021-06-24 18:09           ` Christopher Dimech
  0 siblings, 0 replies; 7+ messages in thread
From: Christopher Dimech @ 2021-06-24 18:09 UTC (permalink / raw)
  To: Rob Sargent; +Cc: emacs-orgmode

The convenience of html output is the easiness by which one can zoom
in and out.  Doing that in printed output is difficult because you need
typefaces with different sizes.

I use the latex for mathematical typesetting, with the other things I 
wholeheartedly follow your drift.  There is still so much work to do.
Things have become complicated, and the design has to get simplified,
for the next generation of hackers to work with.


> Sent: Friday, June 25, 2021 at 5:54 AM
> From: "Rob Sargent" <robjsargent@gmail.com>
> To: emacs-orgmode@gnu.org
> Subject: Re: Latex highlighting for org-mode
>
> On 6/24/21 11:43 AM, Christopher Dimech wrote:
> > I only proposed colour highlighing for mathematical snippets.  Nothing else.
> >
> > Or making org able to export to html even when one is using LaTeX blocks.
> >
> > In that sense, it would act in ways similar to texinfo, using a single
> > source file to produce output in a number of formats, both online and printed.
> >
> >
> Print and digital are vastly different worlds.  Given that one can plop 
> most any file in a web page I would rather see more work on making print 
> layout easier without resorting to latex directives or other single 
> target mark-ups.  Even at the expense of html output.
> 
>


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-24 18:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24  5:07 Latex highlighting for org-mode Christopher Dimech
2021-06-24 16:28 ` Rodrigo Morales
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

Code repositories for project(s) associated with this 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).