loopspace / latex-to-internet

70 stars 1 forks source link

SVG output ? #5

Closed kpym closed 6 years ago

kpym commented 6 years ago

This is not an issue, but a feature question.

I'm wandering is it possible to use for example pgfsys-common-svg.def with your internet class to produce svg text output ?

For example is it possible from

\begin{tikzpicture}
  \draw (0,0) -- (1,1);
\end{tikzpicture}

to obtain directly something like

<svg xmlns="http://www.w3.org/2000/svg">
  <path d="M 0 0 L 1 1" style="stroke:red"/>
</svg>

?

loopspace commented 6 years ago

Do you mean that you want the resulting svg to be embedded in the document?

Simply loading the svg driver should generate a separate svg file which could then be loaded back in using the correct html (https://stackoverflow.com/questions/4476526/do-i-use-img-object-or-embed-for-svg-files seems relevant here). So if that is what you want then it shouldn't be hard.

Embedding the svg directly might be a bit trickier since it would mean subverting the output from the svg driver. Probably possible but the above would be easier.

For what it's worth, at the moment my method for producing a web page with graphics is to use the external library from TikZ and generate the images as pngs when compiling the document with the doc option (this ensures that there's no interference from the internet class in generating them) which are then imported back in the text mode since the external library replaces the tikzpicture environment by an includegraphics command.

kpym commented 6 years ago

Sorry that my question was not clear : what I want is the main produced document to be svg. If I understand well you are capable to produce text file in place of PDF, no ?

Actually even if the svg is a secondary file what I'm looking for is an SVG that is as close as possible to the original TikZ. When I use htlatex (that call dvisvgm I think ?) the produced SVG is not very clean, IMO. So I hoped that using directly output from the common-svg driver would be more cleaner. But may be I'm wrong.

loopspace commented 6 years ago

I'm not sufficiently familiar with how the pgf output system works, so I don't know how the two files pgfsys-tex4ht.def and pgfsys-common-svg.def interact. I'd need to study them a bit to see if it were possible to define a new wrapper.

kpym commented 6 years ago

Do not loose your time, this was a question in case you already know the answer. Thanks anyway !