From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Beck Subject: Re: org-latex-classes with functions, incomplete doc Date: Sun, 10 Feb 2013 18:51:11 +0100 Message-ID: <87zjzcqcq8.fsf@sophokles.streitblatt.de> References: <87txpkrvzi.fsf@sophokles.streitblatt.de> <87bobsf68g.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:50903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4b3r-0003XK-0H for emacs-orgmode@gnu.org; Sun, 10 Feb 2013 12:51:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4b3o-0000CS-Ew for emacs-orgmode@gnu.org; Sun, 10 Feb 2013 12:51:30 -0500 Received: from mo6-p00-ob.rzone.de ([2a01:238:20a:202:5300::1]:12630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4b3o-0000CD-1k for emacs-orgmode@gnu.org; Sun, 10 Feb 2013 12:51:28 -0500 In-Reply-To: <87bobsf68g.fsf@gmail.com> (Nicolas Goaziou's message of "Sun, 10 Feb 2013 18:06:55 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: Florian Beck , emacs-orgmode@gnu.org Thanks for your explanations, very much appreciated. Nicolas Goaziou 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