7

I'm wondering about the best (ie faster) way to create a new Tikz library.

Let's assume I have the components in a PDF/SVG/whatever vector graphic program. There is a possibility to directly convert from SVG to TikZ code (https://github.com/kjellmf/svg2tikz). I could easily perform that task for each component I have. Then I'd have to add anchors / labels to the created shape by post-processing the obtained code.

For example with this shape:

IGBT

I would get the following code:

\definecolor{c010202}{RGB}{1,2,2}
\definecolor{cFFFFFF}{RGB}{255,255,255}


\begin{tikzpicture}[y=0.80pt, x=0.8pt,yscale=-1, inner sep=0pt, outer sep=0pt]
  \path[draw=c010202,line join=round,line cap=round] (311.6780,393.3070) --
    (311.6780,404.6450) -- (297.5060,410.3140) -- (297.5060,410.3140);
  \path[draw=c010202,line join=round,line cap=round] (311.6780,450.0000) --
    (311.6780,438.6610) -- (297.5060,432.9920) -- (297.5060,432.9920);
  \path[draw=c010202,line join=round,line cap=rect,line width=1.600pt]
    (297.5050,404.6460) -- (297.5050,438.6620) -- (297.5050,438.6620);
  \path[draw=c010202] (294.6710,438.6610);
  \path[fill=c010202] (300.9860,436.6890) -- (302.5760,432.7140) .. controls
    (302.6780,432.4570) and (302.9690,432.3330) .. (303.2260,432.4350) .. controls
    (303.2750,432.4560) and (303.3220,432.4840) .. (303.3630,432.5180) --
    (308.5310,436.8910) .. controls (308.7420,437.0700) and (308.7670,437.3840) ..
    (308.5900,437.5950) .. controls (308.4880,437.7160) and (308.3360,437.7810) ..
    (308.1800,437.7720) -- (301.4200,437.3750) .. controls (301.1450,437.3590) and
    (300.9360,437.1220) .. (300.9510,436.8470) .. controls (300.9530,436.7930) and
    (300.9650,436.7400) .. (300.9860,436.6890) -- cycle;
  \path (300.9860,436.6890) -- (302.5760,432.7140) .. controls (302.6780,432.4570)
    and (302.9690,432.3330) .. (303.2260,432.4350) .. controls (303.2750,432.4560)
    and (303.3220,432.4840) .. (303.3630,432.5180) -- (308.5310,436.8910) ..
    controls (308.7420,437.0700) and (308.7670,437.3840) .. (308.5900,437.5950) ..
    controls (308.4880,437.7160) and (308.3360,437.7810) .. (308.1800,437.7720) --
    (301.4200,437.3750) .. controls (301.1450,437.3590) and (300.9360,437.1220) ..
    (300.9510,436.8470) .. controls (300.9530,436.7930) and (300.9650,436.7400) ..
    (300.9860,436.6890) -- cycle;
      \path[draw=c010202,line join=round,line cap=round] (294.6710,404.6460) --
        (294.6710,438.6610) -- (284.7500,438.6610);
          \path[fill=cFFFFFF] (284.7500,438.6610) circle (0.0424cm);
          \path[fill=c010202] (284.7500,436.9570) .. controls (285.6890,436.9570) and
            (286.4540,437.7220) .. (286.4540,438.6610) .. controls (286.4540,439.6000) and
            (285.6890,440.3650) .. (284.7500,440.3650) .. controls (283.8110,440.3650) and
            (283.0460,439.6000) .. (283.0460,438.6610) .. controls (283.0460,437.7220) and
            (283.8100,436.9570) .. (284.7500,436.9570) .. controls (285.6900,436.9570) and
            (283.8100,436.9570) .. (284.7500,436.9570) -- cycle(284.7500,439.9650) ..
            controls (285.4690,439.9650) and (286.0540,439.3810) .. (286.0540,438.6610) ..
            controls (286.0540,437.9420) and (285.4700,437.3570) .. (284.7500,437.3570) ..
            controls (284.0300,437.3570) and (283.4460,437.9420) .. (283.4460,438.6610) ..
            controls (283.4460,439.3810) and (284.0300,439.9650) .. (284.7500,439.9650) ..
            controls (285.4700,439.9650) and (284.0300,439.9650) .. (284.7500,439.9650) --
            cycle;

\end{tikzpicture}

In order to use it easily I would have to add anchors (1 north, 1 south and 1 for gate), plus a label position.

Would this approach be the good way to do it or not?

The other way would be to start from any existing library and modify it to my needs.

closed as unclear what you're asking by yo', Paul Gessler, Joseph Wright Mar 7 '15 at 21:27

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Just to clarify: by 'best' you mean just 'faster to create (the library)'? I ask because 'best' may not coincide with 'fastest'. Also, I guess you mean 'fastest to create initially' and not necessarily 'most time-efficient overall'? Note that you probably will also want to eliminate the mixture of pt and cm else you will get odd effects if you use different font sizes. Do you really need curved lines in that shape? – cfr Jun 15 '14 at 23:01
  • @cfr yes I wouldn't like to loose too much time for doing it. The mixture of cm and pt is what came out of svg2tikz. I for example won't need ultra high flexibility for width/height etc of symbols. But if you think I'd gain in efficiency by doing it the other way around please let us know. – s__C Jun 16 '14 at 5:18

Browse other questions tagged or ask your own question.