summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ximera/src/tikzexport.dtx
blob: c89f26a49ae25aae223890890917d23dff307846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
% \subsubsection{TikZ export}
% We generate SVGs and PNGs for any TikZ images, via the
% ``externalize'' feature of TikZ.
%
% Currently TikZ doesn't compile natively into the website because of
% how the xake bake compilation works.  In order to make Tikz work,
% you need to get the tool \verb|mutool| on the machine that is
% performing \verb|xake bake|.
%    \begin{macrocode}
%<*classXimera>
\ifdefined\HCode
  \tikzexporttrue
\fi

\iftikzexport
  \usetikzlibrary{external}

  \ifdefined\HCode
    % in htlatex, just include the svg files
    \def\pgfsys@imagesuffixlist{.svg}
    
    \tikzexternalize[prefix=./,mode=graphics if exists]
  \else
    % in pdflatex, actually generate the svg files
    \tikzset{
      /tikz/external/system call={
        pdflatex \tikzexternalcheckshellescape
        -halt-on-error -interaction=batchmode
        -jobname "\image" "\\PassOptionsToClass{tikzexport}{ximera}\texsource";
        mutool draw -F svg \image.pdf > \image.svg ;     % mutool adds "1" to filename ????
        mutool draw -o \image.svg \image.pdf ;
        mutool draw -r 150 -c rgbalpha -o \image.png \image.pdf ;
        ebb -x \image.png
      }
    }
    \tikzexternalize[optimize=false,prefix=./]
  \fi

  \fi

%</classXimera>
%    \end{macrocode}