2

I am using org-mode to export to pdf using LaTeX beamer class. How is it possible to change the color of some of the words I use in my slides?

I saw an example that uses the @ symbol: @important@ changes important to the color red. I tried the same example (beamer tutorial) but I could not obtain this effect.

4

Two ways to color text in org-mode come into my mind:

1.) Simply add the usual LaTeX code

@@latex:{\color{green}@@This@@latex:}@@ is green.

2.) Use John Kitchin's org-colored-text.el

After downloading the file to your load-path directory, put the following in your init.el, which lets you use org-links to color text:

(require 'org-colored-text)

;; Taken and adapted from org-colored-text
(org-add-link-type
 "color"
 (lambda (path)
   "No follow action.")
 (lambda (color description backend)
   (cond
    ((eq backend 'latex)                  ; added by TL
     (format "{\\color{%s}%s}" color description)) ; added by TL
    ((eq backend 'html)
     (let ((rgb (assoc color color-name-rgb-alist))
           r g b)
       (if rgb
           (progn
             (setq r (* 255 (/ (nth 1 rgb) 65535.0))
                   g (* 255 (/ (nth 2 rgb) 65535.0))
                   b (* 255 (/ (nth 3 rgb) 65535.0)))
             (format "<span style=\"color: rgb(%s,%s,%s)\">%s</span>"
                     (truncate r) (truncate g) (truncate b)
                     (or description color)))
         (format "No Color RGB for %s" color)))))))

Then use color links like this:

[[color:green][This]] is green.

1

As a complement to @Timm answer, you can define a macro instead of having to write:

@@latex:{\color{green}@@This@@latex:}@@ 

every times.

This is slightly more readable and less verbose. Here is a working example (to export to PDF).

#+LATEX_HEADER: \usepackage{color}
#+MACRO: color @@latex:{\color{$1}@@$2@@latex:}@@

{{{color(red,this text is red)}}} and {{{color(green,this one is green)}}}. 
0

Beamer offers the \alert{} command precisely for that purpose, e.g:

This is \alert{important}

Most often, the text given as argument is typeset in red, less often just in bold, depending on the theme.

If the default behavior does not fit your need, you can change it with:

\setbeamercolor{alerted text}{fg=red}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.