From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kyutech Subject: Re: To interrupt org-latex-pdf-process to regexp-replace some string of the .tex intermediate file and continue to export Date: Sat, 26 Apr 2014 15:06:30 +0900 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11355f2a932a4c04f7ebe4ea Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdvlZ-0007Z9-MI for emacs-orgmode@gnu.org; Sat, 26 Apr 2014 02:07:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WdvlX-0007Ki-NS for emacs-orgmode@gnu.org; Sat, 26 Apr 2014 02:07:13 -0400 Received: from mail-qc0-x229.google.com ([2607:f8b0:400d:c01::229]:32786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdvlX-0007Ke-G9 for emacs-orgmode@gnu.org; Sat, 26 Apr 2014 02:07:11 -0400 Received: by mail-qc0-f169.google.com with SMTP id i17so5017738qcy.0 for ; Fri, 25 Apr 2014 23:07:11 -0700 (PDT) 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" --001a11355f2a932a4c04f7ebe4ea Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable John, thanks you very much. Your code really satisfies my demand. I plan to use your function to replace org-export. Thanks again, and thanks Nick for your explanation. Best regards. On Sat, Apr 26, 2014 at 1:56 AM, John Kitchin wrot= e: > You first export your org-file to latex. the function I sent assumes the > tex file has the same basename as the org-file, and ends in .tex. > > Then, with your org-file as the current buffer, call that function. It > will modify the latex file by replacing your \includegraphics lines with > the equivalent line minus the .png. > > then you need to manually build the latex file if you want the pdf. > > I am not sure what an ebb file is, or what the difference in latex vs > xelatex is. > > https://github.com/jkitchin/jmax/blob/master/ox-manuscript.el > > 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 11:23 AM, Leu Zhe wrote: > >> Dear John=EF=BC=8C >> >> Thanks very much for your help. >> >> I have tried your code but nothing happened. However, I think it is clos= e >> 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? >> >> 2. I use xelatex to render my .tex files. Because xelatex can not >> recognize the boundingbox of both .png and .pdf, >> so I need to generate .ebb for them in seperate folders, which are PN= G >> and PDF folders respectively. so i think >> you did not mention them? >> >> I am studying elisp now, but your code is really difficult for me, so ca= n >> you help me dig in? >> >> Best regard! >> >> >> >> >> On Fri, Apr 25, 2014 at 10:54 PM, John Kitchin = wrote: >> >>> This is how I do what I think you are describing. I just take off the >>> extension, and let (pdf)latex pick the extension it wants. >>> >>> (defun ox-manuscript-remove-image-extensions () >>> "Removes .png extensions from \includegraphics directives in an expor= ted latex file. >>> >>> >>> >>> >>> >>> >>> >>> Run this from an org-buffer after you have exported it to a LaTeX file" >>> (interactive) >>> (let* ((org-file (file-name-nondirectory (buffer-file-name))) >>> (tex-file (replace-regexp-in-string "org$" "tex" org-file)) >>> (tex-contents (with-temp-buffer (insert-file-contents tex-file= ) (buffer-string)))) >>> >>> >>> >>> >>> >>> >>> (message tex-file) >>> (with-temp-file tex-file (insert (replace-regexp-in-string >>> >>> >>> >>> >>> >>> >>> (concat "\\(\\includegraphics" >>> "\\(\[?[^\].*\]?\\)?\\)" = ;; match optional [stuff] >>> >>> >>> >>> >>> >>> >>> "{\\([^}].*\\)\.\\(png\\)= }") >>> "\\1{\\3}" tex-contents))))) >>> >>> >>> >>> >>> >>> >>> >>> >>> 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 Thu, Apr 24, 2014 at 8:46 AM, Leu Zhe wrote: >>> >>>> I am using org-mode to write some article now. Org-mode is really a >>>> great tool to outline a article with great table and image support. >>>> >>>> Org-mode can display inline .png image but not .pdf file. Because now >>>> org-mode can not control the width or height of shown inline image, so= i >>>> use matplotlib to produce low dpi .png image in PNG folder for inline >>>> display and higher dpi pdf image in PDF folder for finally article exp= ort. >>>> >>>> In .org file, the image link is like [[file:PNG\*.png]] and >>>> \includegraphics{PNG\*.png}in the produced .tex file. Then emacs will >>>> use org-latex-pdf-process to render it to pdf file. What I want is >>>> that before or in org-latex-pdf-process, a regexp replace function is >>>> added to replace the \includegraphics{PDF\*.pdf}, and then produce the >>>> final pdf file. >>>> >>>> Can anyone give a hand? >>>> >>> >>> >> > --001a11355f2a932a4c04f7ebe4ea Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
John, thanks you very much.

Your code r= eally satisfies my =C2=A0demand. I plan to use your function to replace org= -export.

Thanks again, and thanks Nick for your ex= planation.

Best regards.=C2=A0


=


On Sat,= Apr 26, 2014 at 1:56 AM, John Kitchin <jkitchin@andrew.cmu.edu&= gt; wrote:
You first ex= port your org-file to latex. the function I sent assumes the tex file has t= he same basename as the org-file, and ends in .tex.

Then, with your org-file as the current buffer, call that functio= n. It will modify the latex file by replacing your \includegraphics lines w= ith the equivalent line minus the .png.

then you need to manually build the latex file if you want the pd= f.

I am not sure what an ebb file is, or what the difference = in latex vs xelatex is.

https://github.com/jki= tchin/jmax/blob/master/ox-manuscript.el

John
<= br>-----------------------------------
John Kitchin
Associate Profess= or
Doherty Hall A207F
Department of Chemical Engineering
Carnegie = Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu

<= /div>

On Fri, Apr= 25, 2014 at 11:23 AM, Leu Zhe <lzhes43@gmail.com> wrote:
Dear John=EF=BC=8C

Thanks very much for= your help.

I have tried your code but nothing hap= pened. However, I think it is close 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?

2. I use xelatex to render my .tex files. Because xelatex can not recogni= ze the boundingbox of both .png and .pdf,=C2=A0
=C2=A0 =C2=A0so I need to generate .ebb for them in seperate folders, = which are PNG and PDF folders respectively. so i think=C2=A0
=C2= =A0 you did not mention them?

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

Best regard!
=C2=A0

<= /div>


On Fri, Apr 25, 2014 at 10:54 PM, John Kitchin <jkitchin@andrew.cmu.= edu> wrote:
This is how I do what I think you are describing. I just t= ake off the extension, and let (pdf)latex pick the extension it wants.
<= div>
(defun ox-manuscript-remove-image-extension= s ()
=C2=A0=C2=A0"Removes .png ext= ensions from \includegraphics directives in an exported latex file.<= /div>

Run this from an org-buffer after you have export= ed it to a LaTeX file"
=C2=A0=C2=A0(interactive)
=C2=A0=C2=A0(let* ((org-f= ile (file-name-nondirectory (= buffer-file-name)))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(tex-file (replace-regexp-in-string "org$" "tex" org-file))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(tex-contents (with-temp-buffer (= insert-file-contents tex-file) (buffer-string))))
=C2=A0=C2=A0=C2=A0=C2=A0(message tex-f= ile)
=C2=A0=C2=A0=C2=A0=C2=A0(with-temp-file tex-file (insert<= /span> (replace-regexp-in-string
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0(concat "\\(\\includegraphics= "
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= "\\(\[?[^\].*\]?\\)?\\)" ;; match option= al [stuff]
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"{\\([^= }].*\\)\.\\(png\\)}")
=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"\\1= {\\3}" tex-contents)))))


Joh= n

-----------------------------------
John Kitchin
Associate P= rofessor
Doherty Hall A207F
Department of Chemical Engineering
Car= negie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu

<= /div>


On Thu, Apr 24, 2014 at 8:46 AM, Leu Zhe= <lzhes43@gmail.com> wrote:

I am using org-mode to write some article now. Org-mode is really a great t= ool to outline a article with great table and image support.

Org-mode can display inline .png image but not .pdf file. Because now org-m= ode can not control the width or height of shown inline image, so i use mat= plotlib to produce low dpi .png image in PNG folder for inline display and = higher dpi pdf image in PDF folder for finally article export.

In .org file, the image link is like=C2=A0[[file:PNG= \*.png]]=C2=A0and=C2=A0\includegraphics{PNG\*= .png}in the produced .tex file. Then emacs will use=C2=A0org-latex-pdf-process=C2=A0to render it to pdf file. Wha= t I want is that before or in=C2=A0org-latex-pdf-pro= cess, a regexp replace function is added to replace the=C2=A0\includegraphics{PDF\*.pdf}, and then produce the fi= nal pdf file.

Can anyone give a hand?





--001a11355f2a932a4c04f7ebe4ea--