Reputation: 2964
I have created a diagram with tikz and pdflatex and converted it to SVG with inkscape. I want to embed the latex code into the .svg file so that others are able to regenerate/modify it. The problem is that tikz code contains lots of --
(to draw lines) and this makes it impossible to add the code as is as an XML comment to SVG (see this other question).
I was thinking about adding it as CDATA but failed so far (i.e. http://validator.w3.org/ does not validate it).
Here is a MWE of what Carlo Cannas suggested:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg2"
version="1.1">
<metadata>
<annotation xmlns="http://www.w3.org/1998/Math/MathML" encoding="TeX">
blah --
</annotation>
</metadata>
</svg>
Upvotes: 2
Views: 1230
Reputation: 3262
You may include it in a metadata
element, as normal text or using other elements.
I'd suggest to include the code in a MathML annotation
element, with the appropriate encoding
attribute. MathML namespace URI is http://www.w3.org/1998/Math/MathML
, so at the end the code will be something like this:
<svg xmlns="[...SVG namespace URI here...]">
<metadata>
<annotation xmlns="http://www.w3.org/1998/Math/MathML" encoding="TeX">
<!-- TeX code here (obviously not in this comment, remove this whole line and write it in a CDATA section or as character data, as you wish) -->
</annotation>
</metadata>
</svg>
Upvotes: 2