From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haochen Xie Subject: Re: Block level specification for tex code html export method Date: Wed, 12 Aug 2015 21:51:55 +0900 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11425c52db8001051d1cafae Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPVVx-0005NR-HD for emacs-orgmode@gnu.org; Wed, 12 Aug 2015 08:52:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPVVs-0000K0-J7 for emacs-orgmode@gnu.org; Wed, 12 Aug 2015 08:52:17 -0400 Received: from mail-ig0-f169.google.com ([209.85.213.169]:37765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPVVs-0000Jd-Ca for emacs-orgmode@gnu.org; Wed, 12 Aug 2015 08:52:12 -0400 Received: by igbpg9 with SMTP id pg9so12601153igb.0 for ; Wed, 12 Aug 2015 05:52:11 -0700 (PDT) Received: from mail-io0-f173.google.com (mail-io0-f173.google.com. [209.85.223.173]) by smtp.gmail.com with ESMTPSA id l14sm2698890ioe.35.2015.08.12.05.52.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2015 05:52:10 -0700 (PDT) Received: by iodt126 with SMTP id t126so18379748iod.2 for ; Wed, 12 Aug 2015 05:52:10 -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 --001a11425c52db8001051d1cafae Content-Type: text/plain; charset=UTF-8 Hi Andreas, Thank you for your code example. I've tried almost the same code which I saw from the thread you referred (with the htlatex initialization, which I'm doing in my .emacs), and indeed got a svg file as expected. But the problem is that when I try to browse the HTML page in chrome, the image is shown as broken. I check the HTML source code, the image is presented in an img tag, pointing to the svg file. My first though was that the svg file isn't recognized because it's not served by a HTTP server instead of being a filesystem link. I then tried to use python SimpleHTTPServer, then python3 -m http.server (the python2 SimpleHTTPServer was serving svg with a wrong Content-Type) but without luck. Today, I tried svg again, and finally figured out the problem: the svg file generated doesn't contain a proper xmlns in the svg tag, so both chrome and internet explorer is interpreting it as a plain xml file instead of rendering it. I guess this is a bug with imagemagick, but when I tried to do some research on this problem I found nothing. Maybe I could find something with more researches, but I don't have time now, and PNG is fine for me. Still, Andreas, thank you very much for helping. Regards, Haochen -- Mail from Haochen Xie On Wed, Aug 12, 2015 at 5:50 PM, Andreas Leha < andreas.leha@med.uni-goettingen.de> wrote: > Hi Haochen, > > You can render svg from latex through org directly. Here is a complete > example including a tikz diagram that that works on my system (once I > tackle a bug in PGF [1]). > It renders > - png by default (and for inlining the image into the org document) > - nothing for latex (directly include the tikz code into the tex document) > - svg for html > > > --8<---------------cut here---------------start------------->8--- > #+LATEX_HEADER: \usepackage{tikz} > > First execute the second code block, to define the convenience macro > and to set the required new variables in ob-latex.el. Then export to > HTML and to pdf to see the tree exported as an SVG image and as > embedded tikz respectively. > > * Tikz test > Here's a tree, exported to both html and pdf. > > #+header: :file (by-backend (html "tree.svg") (latex "tree.tikz") (t > "tree.png")) > #+header: :imagemagick :iminoptions -density 600 :imoutoptions -geometry > 800 > #+header: :results file raw > #+header: :fit yes > #+begin_src latex > \usetikzlibrary{trees} > \begin{tikzpicture} > \node [circle, draw, fill=red!20] at (0,0) {1} > child { node [circle, draw, fill=blue!30] {2} > child { node [circle, draw, fill=green!30] {3} } > child { node [circle, draw, fill=yellow!30] {4} }}; > \end{tikzpicture} > #+end_src > > #+results: > [[file:tree.png]] > > * COMMENT setup > #+begin_src emacs-lisp :results silent > (setq org-babel-latex-htlatex "htlatex") > (defmacro by-backend (&rest body) > `(case (if (boundp 'backend) (org-export-backend-name backend) nil) > ,@body)) > #+end_src > --8<---------------cut here---------------end--------------->8--- > > > Regards, > Andreas > > [1] http://tex.stackexchange.com/a/232739 > > > Haochen Xie writes: > > Hi Fabrice, > > > > Thank you for mentioning dvisvgm. I did some researches on it, and it > seems that as for now, the only way to invoke dvisvgm is to first export > the latex part to dvi, and call dvisvgm > > manually to convert it to svg, then include it in the org file, which, > is too troublesome for me. Is there any plan to add dvisvgm as an > alternative to dvipng and imagemagick? IMO svg > > images will look much better than png (well, in browsers supporting it), > so that's a nice option to have. > > > > Regards, > > > > Haochen > > > > -- > > > > Mail from Haochen Xie > > > > On Tue, Aug 11, 2015 at 5:53 PM, Fabrice Popineau < > fabrice.popineau@supelec.fr> wrote: > > > > > > 2015-08-11 10:47 GMT+02:00 Haochen Xie : > > > > > > Hi Andreas, > > > > Thank you for your reply. I've read the whole thread, and found your > > example (the second link) very useful. Although for some reason, SVG > > image is not working well on my machine (not being displayed in > > chrome, nor on IE. I don't have firefox installed), but since the SVG > > image generated by imagemagick is indeed a raster image, I don't see > > any benefit using SVG over PNG, and exporting to PNG works perfectly. > > > > Use dvisvgm instead of imagemagick to generate the svg file. > > > > Fabrice > > > --001a11425c52db8001051d1cafae Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
= Hi Andreas,

Thank you for your= code example. I've tried almost the same code which
I saw from the t= hread you referred (with the htlatex initialization,
which I'm doing = in my .emacs), and indeed got a svg file as
expected. But the problem is = that when I try to browse the HTML page
in chrome, the image is shown as = broken. I check the HTML source code,
the image is presented in an img ta= g, pointing to the svg file. My
first though was that the svg file isn= 9;t recognized because it's not
served by a HTTP server instead of be= ing a filesystem link. I then
tried to use python SimpleHTTPServer, then = python3 -m http.server (the
python2 SimpleHTTPServer was serving svg with= a wrong Content-Type)
but without luck.

Today, I tried svg a= gain, and finally figured out the problem: the svg
file generated doesn= 't contain a proper xmlns in the svg tag, so both
chrome and internet= explorer is interpreting it as a plain xml file
instead of rendering it.=

I guess this is a bug with imagemagick, but when I tried to do so= me
research on this problem I found nothing. Maybe I could find something=
with more researches, but I don't have time now, and PNG is fine for=
me.

Still, Andreas, thank you very much for helping.

R= egards,

Haochen



--

Mail from Haochen Xie

On Wed, Aug 12, 2015 at 5:50 PM, Andreas Leh= a <andreas.leha@med.uni-goettingen.de> wrot= e:
Hi Haochen,

You can render svg from latex through org directly.=C2=A0 Here is a complet= e
example including a tikz diagram that that works on my system (once I
tackle a bug in PGF [1]).
It renders
- png by default (and for inlining the image into the org document)
- nothing for latex (directly include the tikz code into the tex document)<= br> - svg for html


--8<---------------cut here---------------start------------->8---
#+LATEX_HEADER: \usepackage{tikz}

First execute the second code block, to define the convenience macro
and to set the required new variables in ob-latex.el.=C2=A0 Then export to<= br> HTML and to pdf to see the tree exported as an SVG image and as
embedded tikz respectively.

* Tikz test
Here's a tree, exported to both html and pdf.

#+header: :file (by-backend (html "tree.svg") (latex "tree.t= ikz") (t "tree.png"))
#+header: :imagemagick :iminoptions -density 600 :imoutoptions -geometry 80= 0
#+header: :results file raw
#+header: :fit yes
#+begin_src latex
=C2=A0 \usetikzlibrary{trees}
=C2=A0 \begin{tikzpicture}
=C2=A0 =C2=A0 \node [circle, draw, fill=3Dred!20] at (0,0) {1}
=C2=A0 =C2=A0 child { node [circle, draw, fill=3Dblue!30] {2}
=C2=A0 =C2=A0 =C2=A0 child { node [circle, draw, fill=3Dgreen!30] {3} }
=C2=A0 =C2=A0 =C2=A0 child { node [circle, draw, fill=3Dyellow!30] {4} }};<= br> =C2=A0 \end{tikzpicture}
#+end_src

#+results:
[[file:tree.png]]

* COMMENT setup
#+begin_src emacs-lisp :results silent
=C2=A0 (setq org-babel-latex-htlatex "htlatex")
=C2=A0 (defmacro by-backend (&rest body)
=C2=A0 =C2=A0 `(case (if (boundp 'backend) (org-export-backend-name bac= kend) nil) ,@body))
#+end_src
--8<---------------cut here---------------end--------------->8---


Regards,
Andreas

[1] http://tex.stackexchange.com/a/232739


Haochen Xie <haochenx@acm.org>= ; writes:
> Hi Fabrice,
>
> Thank you for mentioning dvisvgm. I did some researches on it, and it = seems that as for now, the only way to invoke dvisvgm is to first export th= e latex part to dvi, and call dvisvgm
> manually to convert it to svg, then include it in the org file, which,= is too troublesome for me. Is there any plan to add dvisvgm as an alternat= ive to dvipng and imagemagick? IMO svg
> images will look much better than png (well, in browsers supporting it= ), so that's a nice option to have.
>
> Regards,
>
> Haochen
>
> --
>
> Mail from Haochen Xie
>
> On Tue, Aug 11, 2015 at 5:53 PM, Fabrice Popineau <fabrice.popineau@supelec.fr> wrote: >
>
>=C2=A0 2015-08-11 10:47 GMT+02:00 Haochen Xie <haochenx@acm.org>:
>
>
>=C2=A0 Hi Andreas,
>
>=C2=A0 Thank you for your reply. I've read the whole thread, and fo= und your
>=C2=A0 example (the second link) very useful. Although for some reason,= SVG
>=C2=A0 image is not working well on my machine (not being displayed in<= br> >=C2=A0 chrome, nor on IE. I don't have firefox installed), but sinc= e the SVG
>=C2=A0 image generated by imagemagick is indeed a raster image, I don&#= 39;t see
>=C2=A0 any benefit using SVG over PNG, and exporting to PNG works perfe= ctly.
>
>=C2=A0 Use dvisvgm instead of imagemagick to generate the svg file.
>
>=C2=A0 Fabrice



--001a11425c52db8001051d1cafae--