From: Steve Hafner <steve.b.hafner@gmail.com>
To: Andreas Leha <andreas.leha@med.uni-goettingen.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Tikz-->LaTeX/HTML
Date: Mon, 26 Mar 2012 09:11:50 -0600 [thread overview]
Message-ID: <CAOy7MZ+3NqDjZBJd1DOsB6f9944R+1deYy5xdQ1UG3mNBT7KjA@mail.gmail.com> (raw)
In-Reply-To: <877gy7pu9m.fsf@med.uni-goettingen.de>
On Mon, Mar 26, 2012 at 3:48 AM, Andreas Leha
<andreas.leha@med.uni-goettingen.de> wrote:
> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
> Sorry, sent with wrong version, see below:
>
>> Steve Hafner <steve.b.hafner@gmail.com> 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-doc-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/msg01297.html
>>> and http://lists.gnu.org/archive/html/emacs-orgmode/2011-02/msg01302.html.
>>> 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. On the
>>> 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
>> 'org-export-current-backend (though I am not sure, I think there was
>> also 'latexp at some time).
>> 2) If the latex block is evaluated at all and a file argument is
>> present, this will be used. So the block meant to go the latex->PDF
>> route should not contain the :file argument.
>> 3) Even if ":results graphics" or ":results file" is specified, the
>> results of a latex block seem to be wrapped in
>> #+begin_latex...#+end_latex. So for the block meant to go to the
>> html, one way is to specify ":results org". But here I get a
>> spurious ORG-ORG-START ...
>>
>> Anyway, besides that ORG-ORG-START thing, this seems to work on my side:
>>
>> ,----
>> | * Tikz test
>> | #+name: contents
>> | #+begin_src latex :exports (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'latex)) "results" "none") :results latex
>> | \begin{tikzpicture}
>> | \node[red!50!black] (a) {A};
>> | \node (b) [right of=a] {B};
>> | \draw[->] (a) -- (b);
>> | \end{tikzpicture}
>> | #+end_src
>> |
>> | #+begin_src latex :exports (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'latex)) "none" "results") :results file :file test.png :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 400 :fit yes :noweb yes :headers '("\\usepackage{tikz}")
>
> here it should have been :results org
>
>> | <<contents>>
>> | #+end_src
>> `----
>>
>> Regards,
>> Andreas
>
>
> Best,
> Andreas
>
>
>
> PS: BTW, it requires tons of header arguments. These can be split over
> several lines:
> ,----
> | * Tikz test
> | #+name: contents
> | #+header: :exports (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'latex)) "results" "none")
> | #+header: :results latex
> | #+begin_src latex
> | \begin{tikzpicture}
> | \node[red!50!black] (a) {A};
> | \node (b) [right of=a] {B};
> | \draw[->] (a) -- (b);
> | \end{tikzpicture}
> | #+end_src
> |
> | #+header: :exports (if (and (boundp 'org-export-current-backend) (eq org-export-current-backend 'latex)) "none" "results")
> | #+header: :results org :file test.png
> | #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 400
> | #+header: :fit yes :noweb yes :headers '("\\usepackage{tikz}")
> | #+begin_src latex
> | <<contents>>
> | #+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.
For any in-the-dark readers coming across this thread, I needed to put
#+LATEX_HEADER: \usepackage{tikz}
in my file.
Steve
next prev parent reply other threads:[~2012-03-26 15:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-25 22:27 Tikz-->LaTeX/HTML Steve Hafner
2012-03-26 9:30 ` Tikz-->LaTeX/HTML Andreas Leha
2012-03-26 9:48 ` Tikz-->LaTeX/HTML Andreas Leha
2012-03-26 15:11 ` Steve Hafner [this message]
2012-03-26 15:37 ` Tikz-->LaTeX/HTML Steve Hafner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOy7MZ+3NqDjZBJd1DOsB6f9944R+1deYy5xdQ1UG3mNBT7KjA@mail.gmail.com \
--to=steve.b.hafner@gmail.com \
--cc=andreas.leha@med.uni-goettingen.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.