Tikz vers HTML

Voici une petite ruse pour incorporer une figure Tikz dans une page HTML.

LaTeX
\documentclass{article}
 
 
\usepackage[francais]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,xcolor}
 
 
\usepackage{tikz}
\usetikzlibrary{arrows,external}
 
\tikzset{
    png copy/.style={
        external/system call={
            pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource";
            convert -density 300 -transparent white "\image.pdf" "\image.png"
        }
    }
}
\tikzset{png copy}
 
\makeatletter
\@ifpackageloaded{tex4ht}{
\tikzexternalize[mode=only graphics]
\tikzset{png export/.style={/pgf/images/external info,/pgf/images/include external/.code={\includegraphics[width=\pgfexternalwidth,height=\pgfexternalheight]{##1.png}}}}
\tikzset{png export}
}{
\tikzexternalize
\tikzset{pdf export/.style={/pgf/images/external info,/pgf/images/include external/.code={\includegraphics[width=\pgfexternalwidth,height=\pgfexternalheight]{##1.pdf}}}}
\tikzset{pdf export}
}
\makeatother
 
 
 
\begin{document}
{\color{yellow!50!white}
 
 
 
\begin{center}
\tikzstyle{int}=[draw, color=black,fill=yellow, minimum size=2em]
\tikzstyle{init} = [pin edge={<-,thin,yellow!50!white}]
\tikzstyle{fin} = [pin edge={->,thin,yellow!50!white}, pin position = below]
\tikzstyle{sort} = [pin edge={->,thin,yellow!50!white}, pin position = right]
\tikzstyle{entre} = [pin edge={<-,thin,yellow!50!white}, pin position = left]
 
\begin{tikzpicture}[node distance=3.1cm,auto,>=latex']
  \node [int, pin={[init]$2^{53}$}, pin={[fin]$-1$},pin={[sort]$2^{54}$}] (a) {\texttt{twoSum}}; %bloc 1
  \node (b) [left of=a,node distance=1.5cm, coordinate] {a}; % noeud d'entrée
  \node [int,pin={[entre]}, pin={[init]$-(2^{54}-2)$}, pin={[fin]$0$}] (c) [right of=a] {\texttt{twoSum}}; % bloc 2
  \node [coordinate] (end) [right of=c, node distance=1.5cm]{}; % noeud fin
  \draw[->] (b)node[left] {$2^{53}-1$} --(a) ; % entrée
  \draw[->] (c) --(end)node[right] {$2$} ; % fin
 \end{tikzpicture}
\end{center}
}
 
\end{document}

On compile avec pdfLaTeX et l'option shell-escape

Bash
pdflatex -halt-on-error -shell-escape table.tex

puis avec htlatex

Bash
htlatex table.tex

On peut alors obtenir l'image PNG suivante:

IMAGE(http://download.tuxfamily.org/tehessinmath/les_images/table-figure1.png)

Tags

courtesy of webmatter.de