Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Org Mode LaTeX Export - Making TODOs red

I am using Org Mode within Emacs and I am using the Export to LaTeX option. The output is fine, however I would love to show:

  • TODOs as red
  • DONEs as green

So they stand out.

Is there a way?

like image 693
Tahir Hassan Avatar asked Mar 24 '16 10:03

Tahir Hassan


1 Answers

Modyfing the corresponding function from ox-latex.el

I copied the org-latex-format-headline-default-function from ox-latex.el to my .emacs and added the two cases TODO and DONE. I recommend not replacing the original function but putting this in your .emacs.

It will make any "TODO" containing string red, any "DONE" one green when you export to LaTeX. Make sure that you put

#+Latex_header: \usepackage{xcolor}

in your org heading. You can just edit the string after "format" to customize it. You can as well add more cases if you have other todo keywords.

(defun org-latex-format-headline-colored-keywords-function
    (todo todo-type priority text tags info)
        (concat
           (cond ((string= todo "TODO")(and todo (format "{\\color{red}\\bfseries\\sffamily %s} " todo)))
   ((string= todo "DONE")(and todo (format "{\\color{green}\\bfseries\\sffamily %s} " todo))))
            (and priority (format "\\framebox{\\#%c} " priority))
            text
            (and tags
            (format "\\hfill{}\\textsc{%s}"
    (mapconcat (lambda (tag) (org-latex-plain-text tag info))
           tags ":")))))

(setq org-latex-format-headline-function 'org-latex-format-headline-colored-keywords-function)
like image 125
Aaron Meinel Avatar answered Sep 25 '22 15:09

Aaron Meinel