emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Wrapping section within LaTeX environment


From: Xavier Garrido
Subject: Re: [O] Wrapping section within LaTeX environment
Date: Wed, 16 Dec 2015 09:48:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0

Hi Robert,

Le 16/12/2015 04:41, Robert Klein a écrit :
Hi

On 12/13/2015 03:00 PM, Xavier Garrido wrote:
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_SRC

If I read this right, you are writing the \end{correction} when the
headline function is called for the /following/ headline.

Then the (when...) should be outside the (if..) (because the
string-match condition isn't valid anymore).

As far as I understand emacs-lisp, the (when ...) is within the else so when the string match condition is not valid. That's why I do not understand why this complicated filter was not working. Anyway, my second try was much better and easier to understand (I also apply suggestion from John to avoid inclusion of "correction" section title).

Thanks for having a look,
Xavier
--

  |
  |__     GARRIDO Xavier       Laboratoire de l'Accélérateur Linéaire
   /\     NEMO                 Université Paris-Sud 11
  /--\    address@hidden UMR 8607
  |       address@hidden     Batiment 200
  |__     +33 1.64.46.84.28    91898 Orsay Cedex, France





reply via email to

[Prev in Thread] Current Thread [Next in Thread]