我使用tikz和pdflatex创建了一个图表,并使用inkscape将其转换为SVG。我想将乳胶代码嵌入到.svg文件中,以便其他人能够重新生成/修改它。问题是tikz代码包含大量--
(用于绘制线条),这使得无法将代码作为XML注释添加到SVG(请参阅this other question)。
我正考虑将其添加为CDATA但到目前为止失败(即http://validator.w3.org/未对其进行验证)。
以下是Carlo Cannas建议的MWE:
<?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>
答案 0 :(得分:1)
您可以将其包含在metadata
元素中,作为普通文本或使用其他元素。
我建议将代码包含在MathML annotation
元素中,并使用相应的encoding
属性。 MathML名称空间URI是http://www.w3.org/1998/Math/MathML
,因此最后代码将是这样的:
<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>