emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Editing using emacs-lisp after export
@ 2011-11-30 15:03 Mukherjee, Rajat, LAUSANNE, Clinical Operations
  2011-11-30 20:48 ` John Rakestraw
  0 siblings, 1 reply; 3+ messages in thread
From: Mukherjee, Rajat, LAUSANNE, Clinical Operations @ 2011-11-30 15:03 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

Dear Org-mode gurus,

I use org-mode to generate documents with latex and R codes. I also use
some R function (package: Hmisc) to generate latex tables. One of the
functions produces a blank line with-in the table environment which
causes a fatal error in the .tex file. Is there a way that I can use
emacs-lisp commands like "replace-string" from within the .org file to
act on the .tex file that is exported or other "#+options:"  for export
that will do this edit without having to open the .tex file? Thank you
for your help.

Best regards,

Rajat Mukherjee,
Biostatistician

 


[-- Attachment #2: Type: text/html, Size: 5814 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Editing using emacs-lisp after export
  2011-11-30 15:03 Editing using emacs-lisp after export Mukherjee, Rajat, LAUSANNE, Clinical Operations
@ 2011-11-30 20:48 ` John Rakestraw
       [not found]   ` <A1978E681499414BB2D5F2FEAE5DCA133D3315@HQVEVE0022.nestle.com>
  0 siblings, 1 reply; 3+ messages in thread
From: John Rakestraw @ 2011-11-30 20:48 UTC (permalink / raw)
  To: Mukherjee, Rajat, LAUSANNE, Clinical Operations; +Cc: emacs-orgmode

Hi, Rajat --

> I use org-mode to generate documents with latex and R codes. I also use
> some R function (package: Hmisc) to generate latex tables. One of the
> functions produces a blank line with-in the table environment which
> causes a fatal error in the .tex file. Is there a way that I can use
> emacs-lisp commands like "replace-string" from within the .org file to
> act on the .tex file that is exported or other "#+options:"  for export
> that will do this edit without having to open the .tex file? Thank you
> for your help.

I definitely don't consider myself a guru, but I had a similar problem. I
built a function that finds and removes the empty line and then added this
via add-hook to org-export-latex-final-hook. I suspect one of the real
gurus can suggest a better way to do this, but this works for me.

Here's my code that you can adapt as necessary.

--8<---------------cut here---------------start------------->8---
(defun remove-line-from-exam.tex ()

(if (search-forward-regexp "\\documentclass\[[0-9]+pt]{exam}" nil t nil)
    (while (re-search-forward "\\\\question\n\n" nil t)
      (replace-match "\\\\question\n"))))
      
(add-hook 'org-export-latex-final-hook (function remove-line-from-exam.tex))
--8<---------------cut here---------------end--------------->8---

-- 
John Rakestraw

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Editing using emacs-lisp after export
       [not found]   ` <A1978E681499414BB2D5F2FEAE5DCA133D3315@HQVEVE0022.nestle.com>
@ 2011-12-02 15:57     ` John Rakestraw
  0 siblings, 0 replies; 3+ messages in thread
From: John Rakestraw @ 2011-12-02 15:57 UTC (permalink / raw)
  To: Mukherjee, Rajat, LAUSANNE, Clinical Operations; +Cc: emacs-orgmode

Hi, Rajat --

-----Original Message-----
> > From: John Rakestraw [mailto:lists@johnrakestraw.com] 
> > Sent: mercredi 30 novembre 2011 21:48
> > To: Mukherjee,Rajat,LAUSANNE,Clinical Operations
> > Cc: emacs-orgmode@gnu.org
> > Subject: Re: [O] Editing using emacs-lisp after export

> > Hi, Rajat --

> > > I use org-mode to generate documents with latex and R codes. I also
> > > use some R function (package: Hmisc) to generate latex tables. One
> > > of the functions produces a blank line with-in the table environment
> > > which causes a fatal error in the .tex file. Is there a way that I
> > > can use emacs-lisp commands like "replace-string" from within the
> > > .org file to act on the .tex file that is exported or other
> > > "#+options:" for export that will do this edit without having to
> > > open the .tex file? Thank you for your help.

> > I definitely don't consider myself a guru, but I had a similar
> > problem. I built a function that finds and removes the empty line and
> > then added this via add-hook to org-export-latex-final-hook. I suspect
> > one of the real gurus can suggest a better way to do this, but this
> > works for me.

> > Here's my code that you can adapt as necessary.

> > (defun remove-line-from-exam.tex ()

> > (if (search-forward-regexp "\\documentclass\[[0-9]+pt]{exam}" nil t nil)
> >     (while (re-search-forward "\\\\question\n\n" nil t)
> >       (replace-match "\\\\question\n"))))

> > (add-hook 'org-export-latex-final-hook (function
> > remove-line-from-exam.tex))

> Hi John,
> Many thanks for the hint. I tried something similar, it works when I
> export (using L) to temporary buffer but not when I use the usual [l] or
> [d] export options. Is there a different hook that needs to be used
> here? Many thanks.

My set-up works when I export to pdf (using the [d] export option).
Perhaps you could post your adaptation and someone can figure out why your
function doesn't work. 

--John
-- 
John Rakestraw

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-02 15:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-30 15:03 Editing using emacs-lisp after export Mukherjee, Rajat, LAUSANNE, Clinical Operations
2011-11-30 20:48 ` John Rakestraw
     [not found]   ` <A1978E681499414BB2D5F2FEAE5DCA133D3315@HQVEVE0022.nestle.com>
2011-12-02 15:57     ` John Rakestraw

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).