From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: To interrupt org-latex-pdf-process to regexp-replace some string of the .tex intermediate file and continue to export Date: Fri, 25 Apr 2014 19:17:01 -0400 Message-ID: References: <87y4ytwd7s.fsf@alphaville.bos.redhat.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b6d7fb4c0649e04f7e6296f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdpMf-0004sg-LJ for emacs-orgmode@gnu.org; Fri, 25 Apr 2014 19:17:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WdpMd-0003l2-C5 for emacs-orgmode@gnu.org; Fri, 25 Apr 2014 19:17:05 -0400 Received: from mail-pd0-x231.google.com ([2607:f8b0:400e:c02::231]:39680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdpMd-0003ku-0J for emacs-orgmode@gnu.org; Fri, 25 Apr 2014 19:17:03 -0400 Received: by mail-pd0-f177.google.com with SMTP id y10so3627621pdj.36 for ; Fri, 25 Apr 2014 16:17:02 -0700 (PDT) In-Reply-To: <87y4ytwd7s.fsf@alphaville.bos.redhat.com> 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: Nick Dokos Cc: "emacs-orgmode@gnu.org" --047d7b6d7fb4c0649e04f7e6296f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks Nick, for the more helpful explanation than mine ;) The function I provided is part of this file: https://github.com/jkitchin/jmax/blob/master/ox-manuscript.el which I have been working on for publishing scientific manuscripts. This file provides a new export menu option that not only removes the extensions in the latex file, but also replaces the \bibliography{} line with the contents of the .bbl file so that you have a single, standalone tex file for submission. There is even an export and mail option for a pdf ;) With this library installed, you can just type: C-c C-e j m to build your latex file with extensions removed, bibliography replaced, and open the pdf through the regular org-mode export menu. This may be more helpful than trying to do the steps manually as I described. John ----------------------------------- John Kitchin Associate Professor Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 http://kitchingroup.cheme.cmu.edu On Fri, Apr 25, 2014 at 1:06 PM, Nick Dokos wrote: > Leu Zhe writes: > > > Dear John=EF=BC=8C > > > > Thanks very much for your help. > > > > I have tried your code but nothing happened. However, I think it is > close to my remand. > > > > I have some questions about your code: > > > > 1. When should this command be called? Don't I need to call it before > the org-latex-pdf-process? > > > > As it says in the comment: > > "Run this from an org-buffer after you have exported it to a LaTeX file" > > The function assumes that you have already produced a .tex file from > your .org file (e.g. with C-c C-e l l). Then, in your org file buffer > you call it: > > M-x ox-manuscript-remove-image-extensions RET > > > I am studying elisp now, but your code is really difficult for me, so > can you help me dig in? > > What the function does is get the filename for the current buffer > (i.e. the name of your org file), derive the name of the produced > tex file, get the contents of the tex file assigned (as a string) > to tex-contents, do a search-and-replace operation on tex-contents > and write the result back into the tex file. The search-and-replace > operation searches for strings that look like this: > > \includegraphics[...]{foo.png} > > and replaces each occurrence with > > \includegraphics[...]{foo} > > Nick > > > > --047d7b6d7fb4c0649e04f7e6296f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks Nick, for the more helpful explanati= on than mine ;)

The function I provided is part of this file: = h= ttps://github.com/jkitchin/jmax/blob/master/ox-manuscript.el

which I have been working on for publishing scientific manuscripts. Thi= s file provides a new export menu option that not only removes the extensio= ns in the latex file, but also replaces the \bibliography{} line with the c= ontents of the .bbl file so that you have a single, standalone tex file for= submission. There is even an export and mail option for a pdf ;)

With this library installed, you can just type: C-c C-e j m
<= /div>to build your latex file with extensions removed, bibliography replace= d, and open the pdf through the regular org-mode export menu. This may be m= ore helpful than trying to do the steps manually as I described.

John

-------= ----------------------------
John Kitchin
Associate Professor
Dohe= rty Hall A207F
Department of Chemical Engineering
Carnegie Mellon Uni= versity
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu

<= /div>

On Fri, Apr 25, 2014 at 1:06 PM, Nick Do= kos <ndokos@gmail.com> wrote:
Leu Zhe <lzhes43@gm= ail.com> writes:

> Dear John=EF=BC=8C
>
> Thanks very much for your help.
>
> I have tried your code but nothing happened. However, I think it is cl= ose to my remand.=C2=A0
>
> I have some questions about your code:
>
> 1. When should this command be called? =C2=A0Don't I need to call = it before the org-latex-pdf-process?
>

As it says in the comment:

"Run this from an org-buffer after you have exported it to a LaTeX fil= e"

The function assumes that you have already produced a .tex file from<= br> your .org file (e.g. with C-c C-e l l). Then, in your org file buffer
you call it:

=C2=A0 =C2=A0 M-x ox-manuscript-remove-image-extensions RET

> I am studying elisp now, but your code is really difficult for me, so = can you help me dig in?=C2=A0

What the function does is get the filename for the current buffer
(i.e. the name of your org file), derive the name of the produced
tex file, get the contents of the tex file assigned (as a string)
to tex-contents, do a search-and-replace operation on tex-contents
and write the result back into the tex file. The search-and-replace
operation searches for strings that look like this:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \includegraphics[...]{foo.png}

and replaces each occurrence with

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 \includegraphics[...]{foo}

Nick




--047d7b6d7fb4c0649e04f7e6296f--