Org Mode LaTeX Export - 使 TODO 变红

Org Mode LaTeX Export - Making TODOs red

我在 Emacs 中使用 Org 模式,我正在使用导出到 LaTeX 选项。输出很好,但我想展示:

所以他们脱颖而出。

有办法吗?

从ox-latex.el

中修改相应的函数

我将 org-latex-format-headline-default-function 从 ox-latex.el 复制到我的 .emacs 并添加了两个案例 TODO 和 DONE。我建议不要替换原始函数,而是将其放入您的 .emacs 中。

当您导出到 LaTeX 时,它将使包含字符串的任何 "TODO" 变为红色,将任何 "DONE" 变为绿色。确保你把

#+Latex_header:\usepackage{xcolor}

在您的组织标题中。 您可以只编辑 "format" 之后的字符串来自定义它。 如果您有其他待办事项关键字,也可以添加更多案例。

(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)