Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any package that let inserting SVG markups directly in LaTeX and get result image like:

\begin{svg}[version="1.1"]
  <polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:lime;stroke:purple;stroke-width:5;fill-rule:nonzero;"/>
\end{svg}
share|improve this question
1  
As detailed in [tex.stackexchange.com/questions/2099/… to include SVG diagrams in LaTeX?), the nearest I think you'll get is using TikZ and an appropriate \path, but this will not work for arbirtary SVG. –  Joseph Wright Jul 27 '12 at 7:38
    
Do you want to include a listing of svg code, or do you wan to "run" the svg code and include the resulting picture? –  JLDiaz Jul 27 '12 at 8:24
    
@JLDiaz Second one. I want include result picture. Perhaps a package can map SVG code internally to TikZ. –  PHPst Jul 27 '12 at 8:38
add comment

1 Answer

I don't know how to do it in LaTeX, but in ConTeXt you can use the filter module to run a converter, for example inkscape and include the output. Here is an example of this:

\usemodule
  [filter,ipsum]

\define[1]\readSVGfile
  {\externalfigure[#1]}

\defineexternalfilter
  [SVG]
  [filtercommand={inkscape                   \space
      --without-gui                          \space
      --export-ignore-filters                \space
      --export-pdf=\externalfilteroutputfile \space
      --file=\externalfilterinputfile        \space
    },
    readcommand=\readSVGfile,
    output=\externalfilterbasefile.svg]

\starttext

\startSVG
  <?xml version="1.0" encoding="UTF-8"?>
    <svg xmlns="http://www.w3.org/2000/svg" height="88" width="74">
      <polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:lime;   
      stroke:purple;stroke-width:5;fill-rule:nonzero;"/>
  </svg>
\stopSVG

\ipsum
\stoptext

The output:

result

Of course, you need to have inkscape installed for the conversion.

share|improve this answer
    
Thanks, I need a latex solution yet. –  PHPst Jul 29 '12 at 8:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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