[pgf-tikz] converting tikz to the corresponding svg elements

Henri Menke henrimenke at gmail.com
Mon Jul 27 23:39:53 CEST 2020


Dear Gil,

If you want to start writing code, I recommend you start by reading the
TeXbook.  It is the de-facto standard of the TeX macro language:

    https://www.amazon.com/dp/0201134489

If you don't want to spend money, I've also heard good things about TeX
by Topic, which is free to read.  However, this has more of a reference
manual character:

    https://ctan.org/pkg/texbytopic

Once you have a solid understanding of the TeX macro language you can
start reading the PGF/TikZ code and try to understand the
implementation.  The main development is going on at GitHub

    https://github.com/pgf-tikz/pgf

or on the mailing list that we are posting on.

Kind regards,
Henri

On 27/07/20, 16:34, Gil Cohen wrote:
> Dear Henri,
> *Thank you for your patience to write me an answer*,
> I'm well aware of the fact  "in my view this looks like a lot of work for
> diminishing return",
> I have no problem writing this code and contributing to the repo, although
> there will be a learning curve for me :). BUT learning is awesome! ;)
> 
> I guess there are some stages in the preprocessing from converting tex
> (focusing int tikz) into pdf, I'm assuming I need to hook into one of the
> stages in the preprocessing chain r*ight after replacing* the inline macros
> (*Foreach Operation and other macros*) with "aggressive" inlining and
> templates*.*
> 
> I'm well aware there is a learning curve for me but I'm willing  like to
> put substantial efforts to make it work (I like to tweak things)
> Do you have some tips/suggestions? how to start?
> What is the flow of compiling a tex file ? Is there any architecture
> diagram of the compilation process for tex files?
> I'd like to poke/play and start tweaking things and write some code.
> 
> Thank you Henry,
> have a great day!
> 
> 
> *Gil*
> 
> 
> 
> 
> 
> 
> On Mon, 27 Jul 2020 at 06:34, Henri Menke <henrimenke at gmail.com> wrote:
> 
> > Dear Gil,
> >
> > Before answering your questions, I'd like to note that it is very
> > important to provide a reproducible example.  This is not specific to
> > PGF/TikZ but applies to *any* technical problem you will ever report to
> > anyone.  Without clear steps to reproduce it can become impossible to
> > diagnose the problem.  In this case, a proper example would have been
> >
> >     \documentclass[dvisvgm]{article}
> >     \usepackage{tikz}
> >     \begin{document}
> >     \begin{tikzpicture}
> >         \draw (0,0) rectangle (4,4);
> >     \end{tikzpicture}
> >     \end{document}
> >
> > together with the compilation info (that you provided)
> >
> >     lualatex --output-format=dvi exmaple.tex
> >     dvisvgm example.dvi
> >
> > Now to your question.  Originally PGF has had no SVG support, so
> > everything was implemented with PDF output in mind, where no such shapes
> > exist and everything has to be implemented as a sequence of moveto,
> > lineto, and curveto operations.  Take for example a look at how the
> > `rectangle' operation is implemented at [1].  In principle it is
> > possible to output SVG shapes instead of paths, but that is not how it
> > is currently implemented and I think it will be very tricky to adapt all
> > of the low-level code to do this.
> >
> > Also, in my view this looks like a lot of work for diminishing return.
> > I doubt that there a lot of users of the SVG backend and the usefulness
> > of having shapes instead of path is unclear to me.  I guess shapes are
> > useful if you want to apply CSS stylesheets, but then again you can also
> > easily achieve the same styling at the TikZ end, although maybe not as
> > dynamic.
> >
> > Kind regards,
> > Henri
> >
> > [1]
> > https://github.com/pgf-tikz/pgf/blob/bbe2b56fa0d7c0a514663ac578e019c0f6775739/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex#L3337-L3343
> >
> > On 27/07/20, 01:33, Gil Cohen wrote:
> > > I have read the very well written *pgfmanual* and followed the steps on
> > to
> > > convert tikx into svg:
> > >
> > > lualatex --output-format=dvi example
> > > dvisvgm example
> > >
> > > But I found out *all elements are getting converted to svg paths*,
> > > although some are circles, rectangles, Ellipsis.
> > > So I was wondering how to accomplish this?
> > >
> > > for example, for the following tikz lines:
> > >
> > >
> > >
> > > *\begin{tikzpicture}\ draw (0,0) rectangle (4,4);\end{tikzpicture}*
> > >
> > > I would like to convert into the corresponding SVG shape:
> > >
> > >  <rect x="0" y="0" width="4" height="4" />
> > >
> > > I guess I need to hook into one of the compiling stages of tikz/tex
> > files,
> > >
> > > can someone give me some suggestions how to accomplish it?
> > >
> > > Thank you very much
> >


More information about the pgf-tikz mailing list.