From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haochen Xie Subject: Block level specification for tex code html export method Date: Mon, 10 Aug 2015 17:11:02 +0900 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1134b9649b68f3051cf0876e Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOiAw-0002Id-RH for emacs-orgmode@gnu.org; Mon, 10 Aug 2015 04:11:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOiAv-0005JX-CI for emacs-orgmode@gnu.org; Mon, 10 Aug 2015 04:11:18 -0400 Received: from mail-ig0-x233.google.com ([2607:f8b0:4001:c05::233]:38282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOiAv-0005JN-57 for emacs-orgmode@gnu.org; Mon, 10 Aug 2015 04:11:17 -0400 Received: by igfj19 with SMTP id j19so44840023igf.1 for ; Mon, 10 Aug 2015 01:11:16 -0700 (PDT) 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: emacs-orgmode@gnu.org --001a1134b9649b68f3051cf0876e Content-Type: text/plain; charset=UTF-8 Hi, I'm trying to include a diagram drawn with tikz in a document, but couldn't find an elegant way to conditionally export it as png when generating HTML output and raw TeX code when generating PDF. It is possible to use #+OPTIONS: tex:imagemagick to have tex blocks in the document exported as PNG in HTML, but since I have other formulas which will render much better with MathJAX other than embedded PNGs, i really don't want to do it. What I'm currently doing is to use something like #+BEGIN_SRC latex :file diagram.png :results value raw \begin{tikzpicture} \draw (0,0) grid (7,5); \draw (0,0) node[below left] {$A$}; \draw (7,5) node[above right] {$B$}; \fill (0,0) circle (2pt); \fill (7,5) circle (2pt); \end{tikzpicture} #+END_SRC #+RESULTS[da59bc402ce2d1055b5ff471ea7e398c4e0488f5]: [[file:diagram.png]] so that the diagram will be include in the HTML file as a png image, and the pdf file will also include it as a raster image. But this method is rather a workaround. I'd like to see a vector diagram in the pdf file, which could be achieved if there is a way to specify how a block of TeX source code should be handled when exported to HTML regardless to the global settings. So I propose an extension to #+BEGIN_LaTeX block so that a new header :html will control how the specific block will be handled when exporting to HTML. The possible values might be none, t, dvipng, or imagemagick. "none" will ignore the whole block when exporting to HTML, just like the current behavior; "t" will try to call MathJAX to interpret this block of TeX code; and "dvipng" and "imagemagick" will call "dvipng" or "imagemagick" to render a png file to be embedded in the HTML page. If that extension is supported, we could then left the global option tex:t while inline a tex powered figure with great convenience. For example, in my use case, I could then just used the following code to achieve what I want: #+BEGIN_LaTeX :html imagemagick \begin{tikzpicture} \draw (0,0) grid (7,5); \draw (0,0) node[below left] {$A$}; \draw (7,5) node[above right] {$B$}; \fill (0,0) circle (2pt); \fill (7,5) circle (2pt); \end{tikzpicture} #+END_LaTeX As I'm new to org-mode, I may missed something that I could use instead (although I searched the internet very hard). Please feel free to disagree on me and point alternative ways to achieve my goal. Thanks in advance. Best regards, Haochen -- Mail from Haochen Xie --001a1134b9649b68f3051cf0876e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
= Hi,

I'm trying to include = a diagram drawn with tikz in a document, but
couldn't find an elegant= way to conditionally export it as png when
generating HTML output and ra= w TeX code when generating PDF. It is
possible to use

=
#+OPTIONS:= tex:imagemagick

to have tex blocks in the document exported as PN= G in HTML, but since
I have other formulas which will render much better = with MathJAX other
than embedded PNGs, i really don't want to do it. = What I'm currently
doing is to use something like

#+BEGIN_S= RC latex :file diagram.png :results value raw
\begin{tikzpicture}<= /div>
=C2= =A0 \draw (0,0) grid (7,5);
=C2=A0 \draw (0,0) node[below left] {$A$};
= =C2=A0 \draw (7,5) node[above right] {$B$};
=C2=A0 \fill (0,0) circle (2p= t);
=C2=A0 \fill (7,5) circle (2pt);
\end{tikzpicture}
#+END_SRC
#+RESULTS[da59bc402ce2d1055b5ff471ea7e398c4e0488f5]:
[[file:diagram.= png]]

so that the diagram will be include in the HTML file as a pn= g image,
and the pdf file will also include it as a raster image.<= /div>

<= /font>
But this method is rather a workaround. I= 9;d like to see a vector
diagram in the p= df file, which could be achieved if there is a way to
specify how a block of TeX source code should be handled when = exported
to HTML regardless to the global= settings. So I propose an extension
to #= +BEGIN_LaTeX block so that a new header :html will control how the
specific block will be handled when exporting to = HTML. The possible
values might be none, = t, dvipng, or imagemagick. "none" will ignore
the whole block when exporting to HTML, just like the curren= t
behavior; "t" will try to cal= l MathJAX to interpret this block of TeX
= code; and "dvipng" and "imagemagick" will call "dv= ipng" or
"imagemagick" to = render a png file to be embedded in the HTML page.

I= f that extension is supported, we could then left the global option<= /div>
tex:t= while inline a tex powered figure with great convenience. For
=
example, i= n my use case, I could then just used the following code to
achieve what = I want:

#+BEGIN_LaTeX :html imagemagick
\begin{tikzpicture}
= =C2=A0 \draw (0,0) grid (7,5);
=C2=A0 \draw (0,0) node[below left] {$A$};=
=C2=A0 \draw (7,5) node[above right] {$B$};
=C2=A0 \fill (0,0) circle = (2pt);
=C2=A0 \fill (7,5) circle (2pt);
\end{tikzpicture}
<= div class=3D"gmail_default">#+END_LaTeX=

As I'm new to org-mode, I may missed something that I could u= se
instead (although I searched the internet very hard). Please feel free=
to disagree on me and point alternative ways to achieve my goal.<= /div>

<= /font>

Best regards,

Haochen
=

--=

Mail from Haochen Xie
--001a1134b9649b68f3051cf0876e--