emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Florian Beck <fb@miszellen.de>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: Florian Beck <fb@miszellen.de>, emacs-orgmode@gnu.org
Subject: Re: org-latex-classes with functions, incomplete doc
Date: Sun, 10 Feb 2013 18:51:11 +0100	[thread overview]
Message-ID: <87zjzcqcq8.fsf@sophokles.streitblatt.de> (raw)
In-Reply-To: <87bobsf68g.fsf@gmail.com> (Nicolas Goaziou's message of "Sun, 10 Feb 2013 18:06:55 +0100")

Thanks for your explanations, very much appreciated.

Nicolas Goaziou <n.goaziou@gmail.com> 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

  reply	other threads:[~2013-02-10 17:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-10 16:09 org-latex-classes with functions, incomplete doc Florian Beck
2013-02-10 17:06 ` Nicolas Goaziou
2013-02-10 17:51   ` Florian Beck [this message]
2013-02-10 18:20     ` Nicolas Goaziou
2013-02-10 18:59       ` Florian Beck
2013-02-10 21:52         ` Nicolas Goaziou
2013-02-12 23:27           ` Modifying the exporter (was: org-latex-classes with functions, incomplete doc) Florian Beck
2013-02-13 14:03             ` Modifying the exporter Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zjzcqcq8.fsf@sophokles.streitblatt.de \
    --to=fb@miszellen.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).