From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Hafner Subject: Re: Tikz-->LaTeX/HTML Date: Mon, 26 Mar 2012 09:37:18 -0600 Message-ID: References: <87fwcvpv4j.fsf@med.uni-goettingen.de> <877gy7pu9m.fsf@med.uni-goettingen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:49577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCBz8-0004wi-Fs for emacs-orgmode@gnu.org; Mon, 26 Mar 2012 11:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCByy-0007Gf-Qe for emacs-orgmode@gnu.org; Mon, 26 Mar 2012 11:37:30 -0400 Received: from mail-vx0-f169.google.com ([209.85.220.169]:47702) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCByy-0007G0-Ir for emacs-orgmode@gnu.org; Mon, 26 Mar 2012 11:37:20 -0400 Received: by vcbfk14 with SMTP id fk14so5564658vcb.0 for ; Mon, 26 Mar 2012 08:37:18 -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: Andreas Leha Cc: emacs-orgmode@gnu.org On Mon, Mar 26, 2012 at 9:11 AM, Steve Hafner wr= ote: > On Mon, Mar 26, 2012 at 3:48 AM, Andreas Leha > wrote: >> Andreas Leha writes: >> >> Sorry, sent with wrong version, see below: >> >>> Steve Hafner writes: >>> >>>> I'm trying to get a LaTeX scr block with Tikz code either to go native >>>> into LaTeX or to be converted into a PNG file and included in HTML, as >>>> described in http://orgmode.org/worg/org-contrib/babel/languages/ob-do= c-LaTeX.html. >>>> That document refers to a thread on this list in which two example >>>> were given: http://lists.gnu.org/archive/html/emacs-orgmode/2011-02/ms= g01297.html >>>> and http://lists.gnu.org/archive/html/emacs-orgmode/2011-02/msg01302.h= tml. >>>> Both examples behave in a similar way for me on Org-7.8.06, but not in >>>> the way I expected. If I export to PDF then I just get >>>> "[[file:test.png]]" in the PDF where I expected the image to be >>>> visible, and if I export to HTML then nothing is visible in the HTML >>>> file. Either way I export, the file test.png is indeed generated. >>>> >>>> So I wonder if these examples are valid with respect to 7.8.06 or >>>> maybe my expectations are off. I would not think that the PNG file >>>> should be generated for the PDF export, but would expect the image to >>>> be visible when viewing either document. Reading the manual, it seems >>>> that maybe the behavior has changed in the last year with respect to >>>> these examples. >>>> >>>> So I've tried to figure it out with the manual. If I don't worry about >>>> the HTML export, I'm able to set up the document so that the Tikz code >>>> is included into LaTeX in the correct way; not too difficult. =A0On th= e >>>> other hand, if I don't worry about the LaTeX export, I can get the PNG >>>> file to generate but can't get it automatically included into the >>>> HTML. If I could get this second part figured out, then the plan would >>>> be to have an elisp conditional testing on "backend" (if this is still >>>> a valid symbol to test on) that would determine whether on not to >>>> include :file etc. in the header for the src block. Any thoughts? >>>> >>>> --Steve >>> >>> Hi Steve, >>> >>> the examples are indeed out-dated. >>> >>> 1) 'backend is now >>> =A0 =A0'org-export-current-backend (though I am not sure, I think there= was >>> =A0 =A0also 'latexp at some time). >>> 2) If the latex block is evaluated at all and a file argument is >>> =A0 =A0present, this will be used. =A0So the block meant to go the late= x->PDF >>> =A0 =A0route should not contain the :file argument. >>> 3) Even if ":results graphics" or ":results file" is specified, the >>> =A0 =A0results of a latex block seem to be wrapped in >>> =A0 =A0#+begin_latex...#+end_latex. =A0So for the block meant to go to = the >>> =A0 =A0html, one way is to specify ":results org". =A0But here I get a >>> =A0 =A0spurious ORG-ORG-START ... >>> >>> Anyway, besides that ORG-ORG-START thing, this seems to work on my side= : >>> >>> ,---- >>> | * Tikz test >>> | =A0 #+name: contents >>> | =A0 #+begin_src latex :exports (if (and (boundp 'org-export-current-b= ackend) (eq org-export-current-backend 'latex)) "results" "none") :results = latex >>> | =A0 =A0 \begin{tikzpicture} >>> | =A0 =A0 =A0 \node[red!50!black] (a) {A}; >>> | =A0 =A0 =A0 \node (b) [right of=3Da] {B}; >>> | =A0 =A0 =A0 \draw[->] (a) -- (b); >>> | =A0 =A0 \end{tikzpicture} >>> | =A0 #+end_src >>> | >>> | =A0 #+begin_src latex :exports (if (and (boundp 'org-export-current-b= ackend) (eq org-export-current-backend 'latex)) "none" "results") :results = file :file test.png :imagemagick yes :iminoptions -density 600 :imoutoption= s -geometry 400 :fit yes :noweb yes :headers '("\\usepackage{tikz}") >> >> here it should have been :results org >> >>> | =A0 =A0 <> >>> | =A0 #+end_src >>> `---- >>> >>> Regards, >>> Andreas >> >> >> Best, >> Andreas >> >> >> >> PS: BTW, it requires tons of header arguments. =A0These can be split ove= r >> several lines: >> ,---- >> | * Tikz test >> | #+name: contents >> | #+header: :exports (if (and (boundp 'org-export-current-backend) (eq o= rg-export-current-backend 'latex)) "results" "none") >> | #+header: :results latex >> | #+begin_src latex >> | =A0 \begin{tikzpicture} >> | =A0 =A0 \node[red!50!black] (a) {A}; >> | =A0 =A0 \node (b) [right of=3Da] {B}; >> | =A0 =A0 \draw[->] (a) -- (b); >> | =A0 \end{tikzpicture} >> | #+end_src >> | >> | #+header: :exports (if (and (boundp 'org-export-current-backend) (eq o= rg-export-current-backend 'latex)) "none" "results") >> | #+header: :results org :file test.png >> | #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -ge= ometry 400 >> | #+header: :fit yes :noweb yes :headers '("\\usepackage{tikz}") >> | #+begin_src latex >> | =A0 <> >> | #+end_src >> `---- >> >> > > Thank you, Andreas. It now works as expected. I don't have any > problems that I can see with repect to this ORG-ORG-START issue; the > exported files I get look clean. Andreas, I just read your bug report about the ORG-ORG-START issue in which you say the problem disappears with removal of indentation, and in fact I had removed the indentation. Leaving it in I get excess junk. Steve > > For any in-the-dark readers coming across this thread, I needed to put > > #+LATEX_HEADER: \usepackage{tikz} > > in my file. > > Steve