3

I want to change font of TODO/DONE in PDF output of my Org-mode. Is there any way to change font of TODO/DONE keywords (also perhaps also change colors)?

enter image description here

UPDATE: Using dalanicolai reply below, I changed my config with following lines:

(defun my-org-latex-format-headline-function
    (todo todo-type priority text tags _info)
  "Default format function for a headline.
See `org-latex-format-headline-function' for details."
  (concat
   (and todo (format "{\\framebox{\\bfseries\\rfamily\\color{%s} %s}} "
                     (pcase todo-type
                       ('todo "olive")
                       ('done "teal"))
                     todo))
   (and priority (format "\\framebox{\\#%c} " priority))
   text
   (and tags
    (format "\\hfill{}\\textsc{%s}"
        (mapconcat #'org-latex--protect-text tags ":")))))


(setq org-latex-format-headline-function 'my-org-latex-format-headline-function)

enter image description here

Again thanks dalanicolai.

1 Answer 1

3

A similar question was answered here, but I will write a slightly improved version here, namely one that uses the 'todo-type' argument (as was suggested in the comments of the linked answer). The section 'Advanced Export Configuration' of the org manual (see https://orgmode.org/manual/Advanced-Export-Configuration.html) explains how to add custom filters.

We can start from the org-latex-format-headline-default-function and slightly modify it, and use it as the org-latex-format-headline-function as follows:

First add the line:

#+LATEX_HEADER: \usepackage{xcolor}

to the beginning of your org file.

Subsequently, evaluate the following code (e.g. add it to your init file and reload it with M-x eval-buffer):

(defun my-org-latex-format-headline-function
    (todo todo-type priority text tags _info)
  "Default format function for a headline.
See `org-latex-format-headline-function' for details."
  (concat
   (and todo (format "{\\bfseries\\sffamily\\color{%s} %s} "
                     (pcase todo-type
                       ('todo "orange")
                       ('done "green"))
                     todo))
   (and priority (format "\\framebox{\\#%c} " priority))
   text
   (and tags
    (format "\\hfill{}\\textsc{%s}"
        (mapconcat #'org-latex--protect-text tags ":")))))

(setq org-latex-format-headline-function 'my-org-latex-format-headline-function)
2
  • Thank you, this is what I was looking for I'm slightly changing for my preference. I will update my post with my config shortly.
    – Garid
    Nov 24 at 13:13
  • 1
    Great! Your change looks good! Nov 24 at 13:39

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.