gpt4 book ai didi

svg - 使用 dvisvgm 问题将 DVI 转换为 SVG

转载 作者:行者123 更新时间:2023-12-03 23:29:47 24 4
gpt4 key购买 nike

我尝试使用以下步骤来获取 SVG 文件,但似乎输出 SVG 文件显示不正确。

  • 使用 latex 将 latex 代码 test.tex 编译为 dvi 文件。
    \documentclass{standalone}
    \usepackage{tikz}

    \begin{document}
    \begin{tikzpicture}
    \def\r{2cm}
    \node (O) at (0,0) {$O$};
    \draw (0,0) circle (\r);
    \draw[->] (-\r,0)--(\r,0);
    \draw[->] (0,-\r)--(0,\r);
    \end{tikzpicture}
    \end{document}

    使用以下命令行编译为 dvi (test.dvi):
    # latex test.tex
  • 使用 dvisvgm 工具将 dvi 文件转换为 SVG (test.svg)。
    # dvisvgm --no-fonts test.dvi 

  • SVG 文件似乎已成功创建,但在 Chrome 浏览器或 Firefox 中仅显示 O 字符。
    所以我猜 SVG 文件可能有问题。
    SVG文件内容如下:
    <?xml version='1.0' encoding='ISO-8859-1'?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
    <!-- This file was generated by dvisvgm 1.2.2 (x86_64-apple-darwin10.8.0) -->
    <!-- Sat Nov 30 21:38:15 2013 -->
    <svg height='6.8078pt' version='1.1' viewBox='-15.1079 -21.9156 7.87601 6.8078' width='7.87601pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
    <defs>
    <path d='M7.4 -4.36C7.4 -5.97 6.34 -7.05 4.85 -7.05C2.69 -7.05 0.49 -4.78 0.49 -2.45C0.49 -0.79 1.61 0.22 3.05 0.22C5.17 0.22 7.4 -1.97 7.4 -4.36ZM3.11 -0.04C2.12 -0.04 1.42 -0.85 1.42 -2.17C1.42 -2.61 1.56 -4.07 2.33 -5.24C3.02 -6.28 4 -6.8 4.79 -6.8C5.61 -6.8 6.51 -6.24 6.51 -4.75C6.51 -4.03 6.24 -2.47 5.25 -1.24C4.77 -0.63 3.95 -0.04 3.11 -0.04Z' id='g0-79'/>
    </defs>
    <g id='page1' transform='matrix(0.996264 0 0 0.996264 0 0)'>
    <use x='-15.1645' xlink:href='#g0-79' y='-15.1645'/>
    </g>
    </svg>

    dvisvgm 命令有什么问题吗?

    最佳答案

    您可能在禁用 PostScript 支持的情况下运行 dvisvgm。您可以在 dvisvgm FAQ page 上找到有关如何进行检查的更多信息。 .激活 PS 支持后,我得到了正确的结果:

    enter image description here

    <?xml version='1.0'?>
    <!-- This file was generated by dvisvgm 1.5.1 (x86_64-pc-win64) -->
    <!-- Sun Dec 01 20:59:37 2013 -->
    <svg height='113.785pt' version='1.1' viewBox='-72 -72 113.785 113.785' width='113.785pt' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
    <defs>
    <path d='M7.4 -4.36C7.4 -5.97 6.34 -7.05 4.85 -7.05C2.69 -7.05 0.49 -4.78 0.49 -2.45C0.49 -0.79 1.61 0.22 3.05 0.22C5.17 0.22 7.4 -1.97 7.4 -4.36ZM3.11 -0.04C2.12 -0.04 1.42 -0.85 1.42 -2.17C1.42 -2.61 1.56 -4.07 2.33 -5.24C3.02 -6.28 4 -6.8 4.79 -6.8C5.61 -6.8 6.51 -6.24 6.51 -4.75C6.51 -4.03 6.24 -2.47 5.25 -1.24C4.77 -0.63 3.95 -0.04 3.11 -0.04Z' id='g0-79'/>
    </defs>
    <g id='page1' transform='matrix(0.996264 0 0 0.996264 0 0)'>
    <g transform='matrix(1 0 0 1 -3.938 3.4039)'>
    <use x='-15.1645' xlink:href='#g0-79' y='-15.1645'/>
    </g>
    <path d='M41.7418 -15.166C41.7418 -46.5921 16.2639 -72.0701 -15.166 -72.0701C-46.5921 -72.0701 -72.0701 -46.5921 -72.0701 -15.166C-72.0701 16.2639 -46.5921 41.7418 -15.166 41.7418C16.2639 41.7418 41.7418 16.2639 41.7418 -15.166ZM-15.166 -15.166' fill='none' stroke='#000000' stroke-miterlimit='10.0375' stroke-width='0.399994'/>
    <path d='M-72.0701 -15.166H41.2831' fill='none' stroke='#000000' stroke-miterlimit='10.0375' stroke-width='0.399994'/>
    <path d='M40.0834 -16.7658C40.1814 -16.1659 41.2832 -15.2641 41.5812 -15.166C41.2832 -15.0641 40.1814 -14.1662 40.0834 -13.5663' fill='none' stroke='#000000' stroke-linecap='round' stroke-linejoin='round' stroke-miterlimit='10.0375' stroke-width='0.319985'/>
    <path d='M-15.166 41.7418V-71.6113' fill='none' stroke='#000000' stroke-miterlimit='10.0375' stroke-width='0.399994'/>
    <path d='M-16.7658 -70.4115C-16.1659 -70.5096 -15.2641 -71.6113 -15.166 -71.9093C-15.0641 -71.6113 -14.1662 -70.5096 -13.5663 -70.4115' fill='none' stroke='#000000' stroke-linecap='round' stroke-linejoin='round' stroke-miterlimit='10.0375' stroke-width='0.319985'/>
    </g>
    </svg>

    关于svg - 使用 dvisvgm 问题将 DVI 转换为 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20308519/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com