```tex \documentclass[dvisvgm]{article} \usepackage{tikz} \usetikzlibrary{animations} \begin{document} \tikz [animate = { n:shift = { 0s = "{(0,0)}", 2s = "{(0,5mm)}", 4s = "{(5mm,5mm)}", 6s = "{(5mm,10mm)}", 8s = "{(10mm,10mm)}", begin on = {click, of next=begin}}, }]{ \draw[help lines] (0,0) grid (3,3); \path node (n) [fill = blue!20, draw=blue, very thick] {The node}; \node at(0,-2)(begin){开始}; } \end{document} ``` 上面文件命名为 `st.tex`, 编译方式是 `xelatex -no-pdf st.tex` 然后 `dvisvgm st.xdv` 再用 Firefox 打开 st.svg, 看不到原来 tex 文件中的汉字“开始”。 这种情况下如何处理汉字呢?

2 回答2

0
latex3 对 xetex + dvisvgm 的使用方式尚不完全支持,见 https://github.com/latex3/latex3/issues/677 。 使用以下的例子, ```tex % main.tex \ExplSyntaxOn \str_clear:N \c_sys_backend_str \ExplSyntaxOff \documentclass[tikz, dvisvgm]{standalone} \usetikzlibrary{animations} % 使用 ctex 宏包会触发更多与 latex3 当前实现有关的问题 \usepackage{xeCJK} \begin{document} \tikz [animate = { n:shift = { 0s = "{(0,0)}", 2s = "{(0,5mm)}", 4s = "{(5mm,5mm)}", 6s = "{(5mm,10mm)}", 8s = "{(10mm,10mm)}", begin on = {click, of next=begin}}, }] { \draw[help lines] (0,0) grid (3,3); \path node (n) [fill = blue!20, draw=blue, very thick] {The node}; \node at (0,-2) (begin) {开始}; } \end{document} ``` 然后依次执行 ``` xelatex -no-pdf main.tex dvisvgm --zoom=-1 --exact --font-format=woff main.xdv ``` 生成的 svg 中,汉字正常显示。
0
需要支持中文,`\usepackage{ctex}`先支持中文。

作者追问:2020-02-19 19:58

用的是 texlive2019 ```tex \documentclass{article} \usepackage{ctex} \usepackage{tikz} \usetikzlibrary{animations} \begin{document} \pagestyle{empty} \tikz [animate = { n:shift = { 0s = "{(0,0)}", 2s = "{(0,5mm)}", 4s = "{(5mm,5mm)}", 6s = "{(5mm,10mm)}", 8s = "{(10mm,10mm)}", begin on = {click, of next=begin}}, }]{ \draw[help lines] (0,0) grid (3,3); \path node (n) [fill = blue!20, draw=blue, very thick] {The node}; \node at(0,-2)(begin){开始}; } \end{document} ``` 用 `xelatex -no-pdf` 编译报错: Package pgf Warning: Your graphic driver pgfsys-xetex.def does not support animations. This warning is given only once on input line 14. 把 ctex 宏包换成 fontspec 也会出相同的错误。
  • 我尝试了多次,这个问题不容易理解。谢谢关注本问题! – 咸菜的味道 2020-02-20 11:02 回复

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。