Nicolas Goaziou <n.goaz...@gmail.com> writes:
> Anyway, we're back to step one: if you want to handle headlines > differently (i.e. by adding your own properties), you need to fork > `latex' back-end, as explained before. If you encounter problems, you > can post back here. Ok, I took some time to extract a minimal example. It works fine, but on a very low level (see below). Again, the goal is to add an optional argument to sectioning command. The best way I could come up with is this (I omit the `fb/org-export-pdf' function): #+BEGIN_SRC emacs-lisp (defun fb/org-export-modify-headline (headline string) (if (string-match (rx string-start "\\" (group-n 1 (0+ "sub")) (group-n 2 (or "part" "chapter" "section" "paragraph")) (group-n 3 (zero-or-one "\*")) "{" (group-n 4 (minimal-match (0+ (not (any "}"))))) "}") string) (let* ((level (match-string 1 string)) (type (match-string 2 string)) (stars (match-string 3 string)) (title (match-string 4 string)) (toc-title (org-element-property :toc-title headline)) (new-hl (format "\\%s%s%s%s{%s}" (or level "") type (or stars "") (if toc-title (format "[%s]" toc-title) "") title))) (replace-match new-hl t t string 0)) string)) (defun fb/org-latex-headline (headline contents info) (fb/org-export-modify-headline headline (org-export-with-backend 'latex headline contents info))) (org-export-define-derived-backend fb/org-export-pdf latex :translate-alist ((headline . fb/org-latex-headline)) :options-alist ((:toc-title "TOC_TITLE" nil nil t)) :menu-entry (?l 99 ((?d "Export PDF file" fb/org-export-pdf)))) #+END_SRC As you can see, I pull apart the string and then put it back together. (Relatively straightforward in this case, much more involved for, say, links.) In a perfect world, I would have access to these elements and the format string, so I could either modify them before calling `org-export-with-backend' or assemble the string myself. -- Florian Beck