emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] text color + highlight


From: Nick Dokos
Subject: Re: [Orgmode] text color + highlight
Date: Sat, 07 Aug 2010 00:52:47 -0400

Eric Schulte <address@hidden> wrote:

> Hi,
> 
> I've recently seen similar requests on this list.
> 
> The attached patch provides a first pass at this support implementing
> both in-buffer coloring given the following syntax, and html export (I
> don't know the correct LaTeX syntax, but it shouldn't be hard to extend
> this to LaTeX as well).  This uses something like the LaTeX Beamer
> \color{}{} directive, for example...
> 
>   My name is \color{red}{eric} schulte.
> 
> Would result in the word "eric" appearing in red.  Even though I
> implemented the syntax above, I'm *not* recommending this syntax, it
> feels decidedly more like "latex" than "org", it was simply the only
> obvious option for this initial implementation.
> 

Having LaTeX syntax in an org file is not uncommon: you could view
it as a LaTeX fragment that happens to work in other exports (thanks to
your patch), as well as in the fontification of the buffer.

And it *almost* works in LaTeX as is: the only problem is that the LaTeX
\color command (in contrast to yours) is modal: its range extends to the
end of the current group; so unless some pains are taken, *everything*
after \color{red} would be red. But let's assume you chose a slightly
different designator, say \xcolor{red}. THen the following exports to
LaTeX just fine:

--8<---------------cut here---------------start------------->8---
#+LATEX_HEADER: \usepackage{color}
#+LATEX_HEADER: \newcommand{\xcolor}[2]{{\color{#1}#2}}

* test

My name is \xcolor{red}{eric} schulte.
--8<---------------cut here---------------end--------------->8---

Note the inner braces in the definition of \xcolor: they delimit
the group in which the changed color is active.

So it might be a good idea to use a  different designator
than \color and have the LaTeX exporter add the mods above.
The color package is part of the LaTeX core, so it wouldn't cost
anything but processing costs to always include it.

Alternatively, one can play renaming games in LaTeX and that might
free up \color for this use, but that's always a bit more complicated
and can be confusing.

Thanks,
Nick








reply via email to

[Prev in Thread] Current Thread [Next in Thread]