From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xavier Garrido Subject: Re: Wrapping section within LaTeX environment Date: Wed, 16 Dec 2015 09:48:21 +0100 Message-ID: <56712555.5090609@lal.in2p3.fr> References: <566D79E0.3030704@gmail.com> <5670DD65.9020402@roklein.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a97sl-0000bu-45 for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 03:56:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a97sh-0001iD-Tf for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 03:56:23 -0500 Received: from smtp1.lal.in2p3.fr ([134.158.88.100]:55031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a97sh-0001hJ-Nv for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 03:56:19 -0500 In-Reply-To: <5670DD65.9020402@roklein.de> 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: Robert Klein , "emacs-orgmode@gnu.org" Hi Robert, Le 16/12/2015 04:41, Robert Klein a =C3=A9crit : > Hi > > On 12/13/2015 03:00 PM, Xavier Garrido wrote: >> Dear orgers, >> >> I would like to wrap a given org section between =3D\begin,\end=3D LaT= eX >> environment. These sections are identified by a special tag :correctio= n: >> and to initiate the =3D\begin=3D flag I have basically no problem by u= sing >> the org-export-filter-headline-function filter. The problem comes whe= n >> I want to close the environment i.e. when another section starts. I ha= ve >> 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=20 when the string match condition is not valid. That's why I do not=20 understand why this complicated filter was not working. Anyway, my=20 second try was much better and easier to understand (I also apply=20 suggestion from John to avoid inclusion of "correction" section title). Thanks for having a look, Xavier --=20 | |__ GARRIDO Xavier Laboratoire de l'Acc=C3=A9l=C3=A9rateur L= in=C3=A9aire /\ NEMO Universit=C3=A9 Paris-Sud 11 /--\ garrido@lal.in2p3.fr UMR 8607 | garrido@in2p3.fr Batiment 200 |__ +33 1.64.46.84.28 91898 Orsay Cedex, France