[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] org-latex-classes with functions, incomplete doc
From: |
Florian Beck |
Subject: |
Re: [O] org-latex-classes with functions, incomplete doc |
Date: |
Sun, 10 Feb 2013 18:51:11 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Thanks for your explanations, very much appreciated.
Nicolas Goaziou <address@hidden> writes:
> the proper way to do this is to define a derived back-end with
> a custom headline translation function.
Ok, I tried this. There is a problem, however. This is what I came up
with:
#+BEGIN_SRC emacs-lisp
(defun fb/org-latex-headline (headline contents info)
(let* ((full-section (org-latex-headline headline contents info))
(toc-title (if (plist-get info :toc-title)
(org-element-property :toc-title headline)))
(section-regex "\\`\\\\\\(sub\\)*\\(section\\|paragraph\\){")
(new-section
(when (and toc-title
(string-match section-regex full-section))
(let ((subs (match-string 1 full-section))
(section (match-string 2 full-section))
(rest (substring full-section (match-end 0))))
(concat
"\\" subs section "["
;; replace brackets (from `org-latex-headline')
(replace-regexp-in-string
"\\[" "("
(replace-regexp-in-string
"\\]" ")"
toc-title))
"]{" rest)))))
(or new-section
full-section)))
#+END_SRC
As you can see, the solution is much more convoluted.
The reason is that I have to parse the string returned by
`org-latex-headline' or am I missing something? I ran into a similar
problem while adding padding ("\\\\\n" -> "\\\\[0.4em]\n") to table
rows.
IMO, the probem is this: the translation is (mostly) application of
content to a template (a format string), but these templates are build
(mostly, sectioning is actually an exception) inside the default
translation functions. It would be much easier, when this template would
be accessible from "outside", like this:
#+BEGIN_SRC emacs-lisp
(defun my-org-latex-headline (headline contents info)
(let ((sec-format
(plist-get info :sec-format))) ;; or something like that
[modify sec-format]
(plist-put info :sec-format sec-format)
(org-latex-headline)))
#+END_SRC
The same goes for other functions.
--
Florian Beck
- [O] org-latex-classes with functions, incomplete doc, Florian Beck, 2013/02/10
- Re: [O] org-latex-classes with functions, incomplete doc, Nicolas Goaziou, 2013/02/10
- Re: [O] org-latex-classes with functions, incomplete doc,
Florian Beck <=
- Re: [O] org-latex-classes with functions, incomplete doc, Nicolas Goaziou, 2013/02/10
- Re: [O] org-latex-classes with functions, incomplete doc, Florian Beck, 2013/02/10
- Re: [O] org-latex-classes with functions, incomplete doc, Nicolas Goaziou, 2013/02/10
- [O] Modifying the exporter (was: org-latex-classes with functions, incomplete doc), Florian Beck, 2013/02/12
- Re: [O] Modifying the exporter, Nicolas Goaziou, 2013/02/13