1

I am currently working on a website that gererates exercises for students out of a .tex file. for one of these exercises the solution is a plot, which i am using tkiz for. when i use the normal pdflatex command, the plot is functioning as expected. the problem is when i am trying to generate HTML code. then I get two different svg-files. I am at the end of my LaTeX/htlatex capabilities here. any help is appreciated

\documentclass[12pt,a4paper,oneside,ngerman]{scrbook}
\usepackage{pgfplots} %einfügen von plots
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{axis}[grid style={line width=.1pt, draw=gray!10},major grid style={line width=.2pt,draw=gray!50},
xmin=-1.5,xmax=15,
ymin=-0.04,ymax=0.4,
xtick={},ytick={},
minor tick num=5,
enlargelimits={abs=0},
ticklabel style={font=\tiny,fill=white},
axis lines=middle,
axis line style={latex-latex},
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west},
xlabel = {Gewichtskraft [N]},
ylabel = {Auslenkung [cm]},
minor tick num=5
]
\addplot [
mark = x,
only marks
] coordinates{(0.981,0.02488)
    (2.45,0.0633)
    (4.9,0.12847)
    (7.35,0.18416)
    (9.81,0.25201)
    (12.26,0.29808)};
\addplot [color=red, domain=-1.5:15]{0.024529219346691625 *x + 0.0040780298507462065};
\end{axis}
\end{tikzpicture}
\end{document}

This is my MWE, here is the two outputted SVG files: mwe-1.svg:

    <?xml version="1.0" encoding="iso-8859-1" standalone="no"?> 
    <?xml-stylesheet href="mwe.css" type="text/css"?> 
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="295.63168pt" height="187.33652pt" viewBox="-2.05045 -5.30522 295.63168 187.33652 "> 
    <g transform="translate(0, 182.0313 ) scale(1,-1) translate(0,5.30522 )"> 
     <g>?nl <g stroke="rgb(0.0%,0.0%,0.0%)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <g stroke-width="0.4pt">?nl <g>?nl <g>?nl <g>?nl <g>?nl <g stroke-width="0.2pt">?nl <g stroke="rgb(50.0%,50.0%,50.0%)">?nl <g fill="rgb(50.0%,50.0%,50.0%)">?nl <path d=" M  1.96967 13.3044 L  1.96967 16.14995 M  5.90901 13.3044 L  5.90901 16.14995 M  9.84837 13.3044 L  9.84837 16.14995 M  13.78773 13.3044 L  13.78773 16.14995 M  21.66647 13.3044 L  21.66647 16.14995 M  25.60583 13.3044 L  25.60583 16.14995 M  29.54518 13.3044 L  29.54518 16.14995 M  33.48454 13.3044 L  33.48454 16.14995 M  37.4239 13.3044 L  37.4239 16.14995 M  45.30264 13.3044 L  45.30264 16.14995 M  49.242 13.3044 L  49.242 16.14995 M  53.18135 13.3044 L  53.18135 16.14995 M  57.12071 13.3044 L  57.12071 16.14995 M  61.06007 13.3044 L  61.06007 16.14995 M  68.93881 13.3044 L  68.93881 16.14995 M  72.87817 13.3044 L  72.87817 16.14995 M  76.81752 13.3044 L  76.81752 16.14995 M  80.75688 13.3044 L  80.75688 16.14995 M  84.69624 13.3044 L  84.69624 16.14995 M  92.57498 13.3044 L  92.57498 16.14995 M  96.51434 13.3044 L  96.51434 16.14995 M  100.45369 13.3044 L  100.45369 16.14995 M  104.39305 13.3044 L  104.39305 16.14995 M  108.33241 13.3044 L  108.33241 16.14995 M  116.21115 13.3044 L  116.21115 16.14995 M  120.15051 13.3044 L  120.15051 16.14995 M  124.08986 13.3044 L  124.08986 16.14995 M  128.02922 13.3044 L  128.02922 16.14995 M  131.96858 13.3044 L  131.96858 16.14995 M  139.84732 13.3044 L  139.84732 16.14995 M  143.78668 13.3044 L  143.78668 16.14995 M  147.72603 13.3044 L  147.72603 16.14995 M  151.66539 13.3044 L  151.66539 16.14995 M  155.60475 13.3044 L  155.60475 16.14995 M  163.48349 13.3044 L  163.48349 16.14995 M  167.42285 13.3044 L  167.42285 16.14995 M  171.3622 13.3044 L  171.3622 16.14995 M  175.30156 13.3044 L  175.30156 16.14995 M  179.24092 13.3044 L  179.24092 16.14995 M  187.11966 13.3044 L  187.11966 16.14995 M  191.05902 13.3044 L  191.05902 16.14995 M  194.99837 13.3044 L  194.99837 16.14995  " style="fill:none"/>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g stroke-width="0.2pt">?nl <g stroke="rgb(50.0%,50.0%,50.0%)">?nl <g fill="rgb(50.0%,50.0%,50.0%)">?nl <path d=" M  41.3633 12.59323 L  41.3633 16.8611 M  64.99947 12.59323 L  64.99947 16.8611 M  88.63564 12.59323 L  88.63564 16.8611 M  112.2718 12.59323 L  112.2718 16.8611 M  135.90797 12.59323 L  135.90797 16.8611 M  159.54414 12.59323 L  159.54414 16.8611 M  183.18031 12.59323 L  183.18031 16.8611  " style="fill:none"/>?nl </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g>?nl <g stroke-width="0.2pt">?nl <g stroke="rgb(50.0%,50.0%,50.0%)">?nl <g fill="rgb(50.0%,50.0%,50.0%)">?nl <path d=" M  16.3042 2.45451 L  19.15007 2.45451 M  16.3042 8.59082 L  19.15007 8.59082 M  16.3042 20.86348 L  19.15007 20.86348 M  16.3042 26.9998 L  19.15007 26.9998 M  16.3042 33.13612 L  19.15007 33.13612 M  16.3042 39.27245 L  19.15007 39.27245 M  16.3042 45.40875 L  19.15007 45.40875 M  16.3042 57.68141 L  19.15007 57.68141 M  16.3042 63.81773 L  19.15007 63.81773 M  16.3042 69.95406 L  19.15007 69.95406 M  16.3042 76.09038 L  19.15007 76.09038 M  16.3042 82.22668 L  19.15007 82.22668 M  16.3042 94.49934 L  19.15007 94.49934 M  16.3042 100.63567 L  19.15007 100.63567 M  16.3042 106.77199 L  19.15007 106.77199 M  16.3042 112.90831 L  19.15007 112.90831 M  16.3042 119.04462 L  19.15007 119.04462 M  16.3042 131.31728 L  19.15007 131.31728 M  16.3042 137.4536 L  19.15007 137.4536 M  16.3042 143.58992 L  19.15007 143.58992 M  16.3042 149.72624 L  19.15007 149.72624 M  16.3042 155.86255 L  19.15007 155.86255  " style="fill:none"/>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g stroke-width="0.2pt">?nl <g stroke="rgb(50.0%,50.0%,50.0%)">?nl <g fill="rgb(50.0%,50.0%,50.0%)">?nl <path d=" M  15.59291 51.5451 L  19.86133 51.5451 M  15.59291 88.36304 L  19.86133 88.36304 M  15.59291 125.18097 L  19.86133 125.18097 M  15.59291 161.9989 L  19.86133 161.9989  " style="fill:none"/>?nl </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <path d=" M  3.59995 14.72717 L  191.39845 14.72717  " style="fill:none"/>?nl <g>?nl <g transform="matrix(-1.0,0.0,0.0,-1.0,3.59995,14.72717)">?nl <g>?nl <path d=" M  3.59995 0.0 C  2.53328 0.2 0.79999 0.79999 -0.4 1.49997 L  -0.4 -1.49997 C  0.79999 -0.79999 2.53328 -0.2 3.59995 0.0  " style="stroke:none"/>?nl </g>?nl  </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,191.39845,14.72717)">?nl <g>?nl <path d=" M  3.59995 0.0 C  2.53328 0.2 0.79999 0.79999 -0.4 1.49997 L  -0.4 -1.49997 C  0.79999 -0.79999 2.53328 -0.2 3.59995 0.0  " style="stroke:none"/>?nl </g>?nl  </g>?nl </g>?nl <path d=" M  17.72713 3.59995 L  17.72713 158.39896  " style="fill:none"/>?nl <g>?nl <g transform="matrix(0.0,-1.0,1.0,0.0,17.72713,3.59995)">?nl <g>?nl <path d=" M  3.59995 0.0 C  2.53328 0.2 0.79999 0.79999 -0.4 1.49997 L  -0.4 -1.49997 C  0.79999 -0.79999 2.53328 -0.2 3.59995 0.0  " style="stroke:none"/>?nl </g>?nl  </g>?nl </g>?nl <g>?nl <g transform="matrix(0.0,1.0,-1.0,0.0,17.72713,158.39896)">?nl <g>?nl <path d=" M  3.59995 0.0 C  2.53328 0.2 0.79999 0.79999 -0.4 1.49997 L  -0.4 -1.49997 C  0.79999 -0.79999 2.53328 -0.2 3.59995 0.0  " style="stroke:none"/>?nl </g>?nl  </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  35.6138 0.6942 h  11.499 v  11.69904 h  -11.499 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,39.53,4.6104)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(1.8333,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">2</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  59.24997 0.6942 h  11.499 v  11.69904 h  -11.499 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,63.16617,4.6104)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(1.8333,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">4</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  82.88614 0.6942 h  11.499 v  11.69904 h  -11.499 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,86.80234,4.6104)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(1.8333,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">6</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  106.52231 0.6942 h  11.499 v  11.69904 h  -11.499 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,110.4385,4.6104)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(1.8333,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">8</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  128.32516 0.6942 h  15.16562 v  11.69904 h  -15.16562 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,132.24136,4.6104)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(3.66661,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">10</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  151.96133 0.6942 h  15.16562 v  11.69904 h  -15.16562 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,155.87753,4.6104)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(3.66661,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">12</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  175.5975 0.6942 h  15.16562 v  11.69904 h  -15.16562 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,179.5137,4.6104)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(3.66661,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">14</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  -2.05045 45.69559 h  17.44336 v  11.69904 h  -17.44336 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,1.86575,49.61179)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(4.80548,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">0</tspan><tspan font-family="cmmi" font-size="6">.</tspan><tspan font-family="cmr" font-size="6">1</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  -2.05045 82.51352 h  17.44336 v  11.69904 h  -17.44336 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,1.86575,86.42972)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(4.80548,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">0</tspan><tspan font-family="cmmi" font-size="6">.</tspan><tspan font-family="cmr" font-size="6">2</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  -2.05045 119.33145 h  17.44336 v  11.69904 h  -17.44336 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,1.86575,123.24765)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(4.80548,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">0</tspan><tspan font-family="cmmi" font-size="6">.</tspan><tspan font-family="cmr" font-size="6">3</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <g>?nl <g fill="rgb(100.0%,100.0%,100.0%)">?nl <path d=" M  -2.05045 156.14938 h  17.44336 v  11.69904 h  -17.44336 Z  " style="stroke:none"/>?nl </g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,1.86575,160.06558)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(4.80548,0)" text-anchor="middle"  font-size="12"> 
    <tspan font-family="cmr" font-size="6">0</tspan><tspan font-family="cmmi" font-size="6">.</tspan><tspan font-family="cmr" font-size="6">4</tspan></text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <clipPath id="pgfcp1"> <path d=" M  0.0 0.0 L  194.9984 0.0 L  194.9984 161.9989 L  0.0 161.9989 Z  "/>?nl</clipPath>?nl <g clip-path="url(#pgfcp1)">?nl <g>?nl <g stroke="rgb(100.0%,0.0%,0.0%)">?nl <g fill="rgb(100.0%,0.0%,0.0%)">?nl <path d=" M  0.0 2.68188 L  8.12492 8.89081 L  16.24986 15.09972 L  24.37479 21.30864 L  32.49973 27.51755 L  40.62466 33.72647 L  48.74959 39.9354 L  56.87453 46.1443 L  64.99947 52.35323 L  73.12439 58.56213 L  81.24933 64.77104 L  89.37425 70.97997 L  97.49919 77.18887 L  105.62413 83.3978 L  113.74905 89.60672 L  121.874 95.81563 L  129.99893 102.02455 L  138.12386 108.23346 L  146.2488 114.44238 L  154.37372 120.6513 L  162.49866 126.86021 L  170.6236 133.06914 L  178.74852 139.27805 L  186.87346 145.48697 L  194.9984 151.69588  " style="fill:none"/>?nl </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <path d=" M  27.90645 22.47325 L  30.73488 25.30168 M  27.90645 25.30168 L  30.73488 22.47325  " style="fill:none"/>?nl <path d=" M  45.26721 36.6187 L  48.09564 39.44713 M  45.26721 39.44713 L  48.09564 36.6187  " style="fill:none"/>?nl <path d=" M  74.22153 60.61295 L  77.04996 63.44138 M  74.22153 63.44138 L  77.04996 60.61295  " style="fill:none"/>?nl <path d=" M  103.17583 81.11685 L  106.00426 83.94528 M  103.17583 83.94528 L  106.00426 81.11685  " style="fill:none"/>?nl <path d=" M  132.24832 106.09782 L  135.07675 108.92625 M  132.24832 108.92625 L  135.07675 106.09782  " style="fill:none"/>?nl <path d=" M  161.20264 123.05984 L  164.03107 125.88828 M  161.20264 125.88828 L  164.03107 123.05984  " style="fill:none"/>?nl <path d="  " style="fill:none"/>?nl </g>?nl <g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,199.1146,1.61098)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(45.27522,0)" text-anchor="middle"  font-size="12"> 
    Gewichtskraft [N]</text> 
    </g>?nl </g>?nl </g>?nl </g>?nl <g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,21.84332,169.1151)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(42.78705,0)" text-anchor="middle"  font-size="12"> 
    Auslenkung [cm]</text> 
    </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl                                                     </g> 
    </svg> 

mwe-2.svg:

    <?xml version="1.0" encoding="iso-8859-1" standalone="no"?> 
    <?xml-stylesheet href="mwe.css" type="text/css"?> 
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="295.63168pt" height="187.33652pt" viewBox="-2.05045 -5.30522 295.63168 187.33652 "> 
    <g transform="translate(0, 182.0313 ) scale(1,-1) translate(0,5.30522 )"> 
     <g>?nl <g stroke="rgb(0.0%,0.0%,0.0%)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <g stroke-width="0.4pt">?nl <g>?nl <g>?nl </g>?nl <g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,0.0,0.0)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(0.0,0)" text-anchor="middle"  font-size="12"> 
    </text> 
    </g>?nl </g>?nl </g>?nl <g>?nl </g>?nl <g>?nl </g>?nl <g>?nl </g>?nl <g>?nl </g>?nl <g>?nl <g transform="matrix(1.0,0.0,0.0,1.0,-2.05045,-5.30522)">?nl <g fill="rgb(0.0%,0.0%,0.0%)">?nl <text style="stroke:none" transform="scale(1,-1) translate(149.77415,0)" text-anchor="middle"  font-size="12"> 
    <object data="mwe-1.svg" width="395.17407 " height="250.78107 " type="image/svg+xml"><p>SVG-Viewer needed.</p></object></text> 
    </g>?nl </g>?nl </g>?nl <g>?nl </g>?nl <g>?nl </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl </g>?nl 
                                                                               </g> 
    </svg> 

From my understanding it creates 2 svg files, one with the actual data of the plot oan one with nothing in it. the only one referenced in the output HTML is mwg-2.svg

That being said, i have no idea how to read svg files. Wehn i open the HTML file in a browser, it comes up blank, but the source references mwe-2.svg

Again, any help is much appreciated

1

I don't know the source of your issue, but there is a lot of issues with the default TikZ tex4ht driver. There are two possible solutions:

  • use the TikZ externalization
  • use alternative tex4ht driver which uses dvisvgm for the TikZ to SVG conversion.

The simpler solution is the second one, it's main issue is that it doesn't work with utf8 and OpenType fonts, but you don't seem to use it, so I guess that it is OK.

Save the following code as pgfsys-tex4ht.def in the directory with your TeX file:

% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\ProvidesFileRCS $Header: /cvsroot/pgf/pgf/generic/pgf/systemlayer/pgfsys-tex4ht.def,v 1.25 2013/08/06 17:46:08 tantau Exp $



% Driver commands for tex4ht

%
% Load common pdf commands:
%
  %\input pgfsys-dvisvgm.def
  \input pgfsys-dvips.def

%
% tex4ht-specific stuff:
%

\newcount\pgf@sys@svg@picnum

% configure the output picture format to svg
\AtBeginDocument{
  \Configure{Picture}{.svg}
}


% Make the code inserted by tex4ht configurable

\NewConfigure{tikzpicture}{2}
\Configure{tikzpicture}{%
  % \ifvmode\IgnorePar\fi\EndP%\HtmlParOff
  \Picture*{}
}{\EndPicture}

\let\orig@pgfsys@begin\pgfsys@beginpicture
\let\orig@pgfsys@end\pgfsys@endpicture
\def\pgf@sys@postscript@header#1{{\special{! #1}}}
\def\pgfsys@beginpicture{%
  \bgroup
  \csname a:tikzpicture\endcsname
  \pgf@sys@postscript@header{
    /pgfsc{}bind def% stroke color is empty by default
    /pgffc{}bind def% fill color is empty by default
    /pgfstr{stroke}bind def%
    /pgffill{fill}bind def%
    /pgfeofill{eofill}bind def%
    /pgfe{a dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath}bind def% rectangle
    /pgfw{setlinewidth}bind def% setlinewidth
    /pgfs{save pgfpd 72 Resolution div 72 VResolution div neg scale 
      magscale{1 DVImag div dup scale}if 
      pgfx neg pgfy neg translate pgffoa .setopacityalpha}bind def% save
    /pgfr{pgfsd restore}bind def %restore
    userdict begin%
    /pgfo{pgfsd /pgfx currentpoint /pgfy exch def def @beginspecial}bind def %open
    /pgfc{newpath @endspecial pgfpd}bind def %close
    /pgfsd{globaldict /pgfdelta /delta where {pop delta} {0} ifelse put}bind def% save delta
    /pgfpd{/delta globaldict /pgfdelta get def}bind def % put delta
    /.setopacityalpha where {pop} {/.setopacityalpha{pop}def} ifelse % install .setopacityalpha 
    /.pgfsetfillopacityalpha{/pgffoa exch def
      /pgffill{gsave pgffoa .setopacityalpha fill 1 .setopacityalpha newpath fill grestore newpath}bind def
      /pgfeofill{gsave pgffoa .setopacityalpha eofill 1 .setopacityalpha newpath eofill grestore newpath}bind def}bind def
    /.pgfsetstrokeopacityalpha{/pgfsoa exch def /pgfstr{gsave pgfsoa .setopacityalpha stroke grestore newpath}bind def}bind def
    /pgffoa 1 def
    /pgfsoa 1 def
    end
  }%
  \orig@pgfsys@begin%
}%


\def\pgfsys@endpicture{%
  % Save the bounding box
  %\printdim%
  \orig@pgfsys@end%
  \csname b:tikzpicture\endcsname%
  \egroup
  \par% FIXME : was '\Par' but that seems to be undefined!?
}%


\endinput


%%% Local Variables: 
%%% mode: latex
%%% End: 

If you have up to date tex4ht distribution (included in TeX Live), your document should be rendered in this way in the browser:

enter image description here

  • Thank you for your help. i have added the new driver file and it works. Although i do not exactly understand why... – Stephan Fabry Mar 12 '18 at 19:41
  • @StephanFabry it works because it uses a different method for the conversion. The default driver writes the SVG code directly, this one uses dvisvgm, which can use include fonts for example, resulting in much better results. – michal.h21 Mar 12 '18 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.