组织模式LaTeX导出-使待办事项变为红色

Tah*_*san 6 emacs latex org-mode

我正在Emacs中使用组织模式,并且正在使用“导出到LaTeX”选项。输出很好,但是我想显示:

  • 待办事项显示为红色
  • 完成为绿色

所以他们脱颖而出。

有办法吗?

Aar*_*nel 5

从 ox-latex.el 修改相应的函数

我将 org-latex-format-h​​eadline-default-function 从 ox-latex.el 复制到我的 .emacs 并添加了两个案例 TODO 和 DONE。我建议不要替换原来的函数,而是把它放在你的 .emacs 中。

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

#+Latex_header: \usepackage{xcolor}

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

(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)
Run Code Online (Sandbox Code Playgroud)