|
| From: | Xavier Garrido |
| Subject: | [O] Wrapping section within LaTeX environment |
| Date: | Sun, 13 Dec 2015 15:00:00 +0100 |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
Dear orgers,I would like to wrap a given org section between =\begin,\end= LaTeX environment. These sections are identified by a special tag :correction: and to initiate the =\begin= flag I have basically no problem by using the org-export-filter-headline-function filter. The problem comes when I want to close the environment i.e. when another section starts. I have try this piece of code
#+BEGIN_SRC emacs-lisp
(setq correction-flag nil)
(defun cpp-correction-headline (contents backend info)
(if (and (org-export-derived-backend-p backend 'latex)
(string-match "\\`.*correction.*\n" (downcase contents)))
(progn
(setq correction-flag t)
(replace-match "\\\\begin{correction}" nil nil contents)
)
(when correction-flag
(setq correction-flag nil)
(concat "\\end{correction}" contents))
)
)
(add-to-list 'org-export-filter-headline-functions
'cpp-correction-headline)
#+END_SRCbut I get several =\end{correction}= in the produced LaTeX file. Actually this is much more a emacs-lisp related question since the boolean =correction-flag= seems not to work and I don't know why (of course I have very little knowledge in lisp). Can some emacs-lisp experts helps me understand why the above code just does not work.
Thanks a lot, Xavier
| [Prev in Thread] | Current Thread | [Next in Thread] |