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>