summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ximera/src/tikzexport.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/ximera/src/tikzexport.dtx')
-rw-r--r--macros/latex/contrib/ximera/src/tikzexport.dtx42
1 files changed, 42 insertions, 0 deletions
diff --git a/macros/latex/contrib/ximera/src/tikzexport.dtx b/macros/latex/contrib/ximera/src/tikzexport.dtx
new file mode 100644
index 0000000000..c89f26a49a
--- /dev/null
+++ b/macros/latex/contrib/ximera/src/tikzexport.dtx
@@ -0,0 +1,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}