From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xavier Garrido Subject: Re: Wrapping section within LaTeX environment Date: Mon, 14 Dec 2015 08:06:14 +0100 Message-ID: <566E6A66.9070604@gmail.com> References: <566D79E0.3030704@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8NDA-00017c-Va for emacs-orgmode@gnu.org; Mon, 14 Dec 2015 02:06:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a8ND7-0007YW-Pj for emacs-orgmode@gnu.org; Mon, 14 Dec 2015 02:06:20 -0500 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:35390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8ND7-0007YR-IC for emacs-orgmode@gnu.org; Mon, 14 Dec 2015 02:06:17 -0500 Received: by mail-wm0-x22b.google.com with SMTP id p66so30106315wmp.0 for ; Sun, 13 Dec 2015 23:06:17 -0800 (PST) In-Reply-To: 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: John Kitchin Cc: "emacs-orgmode@gnu.org" Le 14/12/2015 02:39, John Kitchin a écrit : > could you provide a brief example of what you want to happen? > > i.e. are you looking for this: > > * some heading :correction: > one line of content > > to convert to this in LaTeX? > > \begin{correction} > one line of content > \end{correction} > Exactly. Actually when I read your mail I realize that =org-export-filter-headline-functions= filter not only give access to the heading but to the whole content within the heading. So, #+BEGIN_SRC emacs-lisp (defun cpp-correction-headline (contents backend info) (when (and (org-export-derived-backend-p backend 'latex) (string-match "\\`.*correction.*\n" (downcase contents))) (concat "\\begin{correction}" (replace-regexp-in-string "\\`.*correction.*\n" "" contents) "\\end{correction}")) ) (add-to-list 'org-export-filter-headline-functions 'cpp-correction-headline) #+END_SRC is doing what I want. So thanks for the insights and sorry for the noise. Xavier > > Xavier Garrido writes: > >> 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 >> >> but 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 > > -- > Professor John Kitchin > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu >