svg 包无法渲染包含数学的 svg

svg 包无法渲染包含数学的 svg

我有一个方程式的 svg 文件,如下所示

<svg xmlns="http://www.w3.org/2000/svg" xmlns:wrs="http://www.wiris.com/xml/cvs-extension" height="29" width="85" wrs:baseline="20"><!--MathML: <math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="script">l</mi><msqrt><mpadded lspace="-4px"><mn>8</mn><mi>&#x3C0;</mi><msub><mi>&#x3B5;</mi><mn>0</mn></msub><mi>m</mi><mi>g</mi></mpadded></msqrt></math>--><defs><style type="text/css">@font-face{font-family:'math1437d7d1d97917cd627a34a6a0f';src:url(data:font/truetype;charset=utf-8;base64,AAEAAAAMAIAAAwBAT1MvMi7iBBMAAADMAAAATmNtYXDEvmKUAAABHAAAADRjdnQgDVUNBwAAAVAAAAA6Z2x5ZoPi2VsAAAGMAAAAt2hlYWQQC2qxAAACRAAAADZoaGVhCGsXSAAAAnwAAAAkaG10eE2rRkcAAAKgAAAACGxvY2EAHTwYAAACqAAAAAxtYXhwBT0FPgAAArQAAAAgbmFtZaBxlY4AAALUAAABn3Bvc3QB9wD6AAAEdAAAACBwcmVwa1uragAABJQAAAAUAAADSwGQAAUAAAQABAAAAAAABAAEAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAgICAAAAAg1UADev96AAAD6ACWAAAAAAACAAEAAQAAABQAAwABAAAAFAAEACAAAAAEAAQAAQAAA8D//wAAA8D///xBAAEAAAAAAAABVAMsAIABAABWACoCWAIeAQ4BLAIsAFoBgAKAAKAA1ACAAAAAAAAAACsAVQCAAKsA1QEAASsABwAAAAIAVQAAAwADqwADAAcAADMRIRElIREhVQKr/asCAP4AA6v8VVUDAAABAFUAAALAAkAAGQBBGAGwGhCwDdSwDRCwB9SwBxCwBNSwBBCwGNQAsBoQsAvUsBoQsALUsBoQsA/UsA8QsBTUsA8QsAY8sA8QsBc8MDElBiMiNQMjERQGKwE2NTQnIhUjNDMhFSMTFALAFUCAAaopAVUqAVVAagIBgQFVVdUBFv7qlUBAlYCWK4BV/urAAAABAAAAAQAA1XjOQV8PPPUAAwQA/////9Y6E3P/////1joTcwAA/yAEgAOrAAAACgACAAEAAAAAAAEAAAPo/2oAABdwAAD/tgSAAAEAAAAAAAAAAAAAAAAAAAACA1IAVQMWAFUAAAAAAAAAKAAAALcAAQAAAAIAXgAFAAAAAAACAIAEAAAAAAAEAADeAAAAAAAAABUBAgAAAAAAAAABABIAAAAAAAAAAAACAA4AEgAAAAAAAAADADAAIAAAAAAAAAAEABIAUAAAAAAAAAAFABYAYgAAAAAAAAAGAAkAeAAAAAAAAAAIABwAgQABAAAAAAABABIAAAABAAAAAAACAA4AEgABAAAAAAADADAAIAABAAAAAAAEABIAUAABAAAAAAAFABYAYgABAAAAAAAGAAkAeAABAAAAAAAIABwAgQADAAEECQABABIAAAADAAEECQACAA4AEgADAAEECQADADAAIAADAAEECQAEABIAUAADAAEECQAFABYAYgADAAEECQAGAAkAeAADAAEECQAIABwAgQBNAGEAdABoACAARgBvAG4AdABSAGUAZwB1AGwAYQByAE0AYQB0AGgAcwAgAEYAbwByACAATQBvAHIAZQAgAE0AYQB0AGgAIABGAG8AbgB0AE0AYQB0AGgAIABGAG8AbgB0AFYAZQByAHMAaQBvAG4AIAAxAC4AME1hdGhfRm9udABNAGEAdABoAHMAIABGAG8AcgAgAE0AbwByAGUAAAMAAAAAAAAB9AD6AAAAAAAAAAAAAAAAAAAAAAAAAAC5BxEAAI2FGACyAAAAFRQTsQABPw==)format('truetype');font-weight:normal;font-style:normal;}@font-face{font-family:'scriptdf906bde6d2bb9848a5f23b35';src:url(data:font/truetype;charset=utf-8;base64,AAEAAAANAIAAAwBQT1MvMlzOErEAAADcAAAATmNtYXAedkzVAAABLAAAAFhjdnQgAEkAkwAAAYQAAAAIZnBnbVO0L6cAAAGMAAACZWdseWZvPbLzAAAD9AAAAVNoZWFkEwIm0gAABUgAAAA2aGhlYRCSFtkAAAWAAAAAJGhtdHhcrhGOAAA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MAYwByAGkAcAB0AFMAYwByAGkAcAB0AFYAZQByAHMAaQBvAG4AIAAxAC4AMFNjcmlwdAAAAAMAAAAAAAAEAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAC4Af+FsAGNAEuwCFBYsQEBjlmxRgYrWCGwEFlLsBRSWCGwgFkdsAYrXFhZsBQrAAA=)format('truetype');font-weight:normal;font-style:normal;}</style></defs><text font-family="scriptdf906bde6d2bb9848a5f23b35" font-size="16" text-anchor="middle" x="4.5" y="20">&#x1D4C1;</text><polyline fill="none" points="12,-22 11,-22 5,0 2,-9" stroke="#000000" stroke-linecap="square" stroke-width="1" transform="translate(9.5,26.5)"/><polyline fill="none" points="5,0 2,-9 0,-8" stroke="#000000" stroke-linecap="square" stroke-width="1" transform="translate(9.5,26.5)"/><line stroke="#000000" stroke-linecap="square" stroke-width="1" x1="21.5" x2="83.5" y1="4.5" y2="4.5"/><text font-family="Arial" font-size="16" text-anchor="middle" x="23.5" y="20">8</text><text font-family="math1437d7d1d97917cd627a34a6a0f" font-size="16" font-style="italic" text-anchor="middle" x="34.5" y="20">&#x3C0;</text><text font-family="Arial" font-size="16" font-style="italic" text-anchor="middle" x="43.5" y="20">&#x3B5;</text><text font-family="Arial" font-size="12" text-anchor="middle" x="51.5" y="25">0</text><text font-family="Arial" font-size="16" font-style="italic" text-anchor="middle" x="61.5" y="20">m</text><text font-family="Arial" font-size="16" font-style="italic" text-anchor="middle" x="72.5" y="20">g</text></svg>

看起来像这样 图像名称.svg

我尝试使用包\includesvg中的命令将其导入到我的 PDF 中svg。包将其转换为image-name_svg-tex.pdf如下所示的文件

图像名称_svg-tex.pdf

渲染我的 PDF 时,出现包inputenc错误,未找到 unicode 字符。我猜是因为svg包尝试将其渲染为简单的 latex 而不是数学。

我如何获取\includesvg命令来渲染我的数学字符?

答案1

您有几种不同的选择,具体取决于您实际需要解决的问题。

如果您不想生成相同的输出,而是包含转换器不支持的 SVG 图形,则可以使用外部工具将 SVG 转换为带有嵌入字体的 PDF(或使用 生成 PDF \documentclass{standalone})。然后,使用graphicx而不是 SVG 包含 PDF。这可以将 OpenType 字体嵌入 PDFTeX 文档,并允许复制和搜索它们。当您被迫使用旧版工具时,这也是插入具有复杂脚本的语言的单词或短语的好方法。

如果您可以使用unicode-math,则可以用 Arial 或无衬线数学字体编写此表达式,而无需经过 SVG 或 MathML。

\documentclass{article}
\usepackage{unicode-math}

\defaultfontfeatures{ Scale=MatchLowercase, Ligatures=TeX }
\setmainfont{Arial}[Scale=1.0]
\setmathfont{Fira Math}
\setmathfont{Arial}[range=up]
\setmathfont{Arial Italic}[range=it]
\setmathfont{Arial Bold}[range=bfup]
\setmathfont{Arial Bold Italic}[range=bfit]

\newcommand\epsilonnought{\varepsilon_{\scriptscriptstyle 0}}

\begin{document}
\[ \ell \sqrt{8 \pi \epsilonnought m g }
\]
\end{document}

Arial + Fira Math 示例

(是的,这个字体的下标 0 太低了。)

如果您使用 PDFLaTeX,则可以使用 URW Arial 作为替代:

\documentclass{article}
\usepackage{amsmath}
\usepackage[T1]{fontenc}
\usepackage{arevmath}
\usepackage{uarial}
\renewcommand\familydefault{\sfdefault}
\usepackage[italic]{mathastext}

\newcommand\epsilonnought{\varepsilon_{\scriptscriptstyle 0}}

\begin{document}
\[ \ell \sqrt{8 \pi \epsilonnought m g }
\]
\end{document}

URW Arial + Arev Math 示例

相关内容