manim
manim copied to clipboard
weird baseline issue in multilanguage LaTeX objects
Description of bug / unexpected behavior
When mixing Chinese script and Western text inside the same Tex()
object using the TexTemplateLibrary.ctex
or XeLaTeX directly, the baselines of the Chinese script is not adjusted to the rest of the text. Running the same code on Docker with Manim v0.16.0 results in a correct rendering.
Expected behavior
The baseline generated by LaTeX/XeLaTeX should be preserved.
How to reproduce the issue
Code for reproducing the problem
class MyScene2(Scene):
def construct(self):
tex = Tex(r'Hallo 你好 \LaTeX', tex_template=TexTemplateLibrary.ctex).scale_to_fit_width(12)
self.add(tex)
self.wait()
Additional media files
Images/GIFs
XeLaTeX output:Docker
Manim v0.17.3
System specifications
System Details
- OS: Windows 10
- Python version 3.9.8
- XeTeX, Version 3.141592653-2.6-0.999995 (MiKTeX 23.5)
Additional comments
same unwanted behavior is observed on the Manimator on Discord
Conversion using a xetex-generated .pdf instead of .xdv works:
class MyScene3(Scene):
def construct(self):
template = TexTemplateLibrary.ctex
template.output_format=".pdf"
tex = Tex(r'Hello 你好 \LaTeX', tex_template=template).scale_to_fit_width(12)
self.add(tex)
self.wait()
Actually this bug is brought by dvisvgm
program.
dvisvgm
involves converting dvi
/xdv
format generated by LaTeX into SVG picture, the latter being what manim
is really operating with. You can check the cache files in media
folder and find some LaTeX files and corresponding xdv
and SVG files.
I suggest you can collect all these files and report an issue to https://github.com/mgieseki/dvisvgm.
EDIT: MWE.tex for this case:
\documentclass[preview]{standalone}
\usepackage{xeCJK}
\setCJKmainfont{SimSun}
\begin{document}
Hallo 你好 \LaTeX
\end{document}
Commands for generating xdv
and SVG file:
xelatex -no-pdf MWE.tex
dvisvgm -n MWE.xdv
Actually this bug is brought by
dvisvgm
program.dvisvgm
involves convertingdvi
/xdv
format generated by LaTeX into SVG picture, the latter being whatmanim
is really operating with. You can check the cache files inmedia
folder and find some LaTeX files and correspondingxdv
and SVG files.I suggest you can collect all these files and report an issue to https://github.com/mgieseki/dvisvgm.
EDIT: MWE.tex for this case:
\documentclass[preview]{standalone} \usepackage{xeCJK} \setCJKmainfont{SimSun} \begin{document} Hallo 你好 \LaTeX \end{document}
Commands for generating
xdv
and SVG file:xelatex -no-pdf MWE.tex dvisvgm -n MWE.xdv
Conversion using a xetex-generated .pdf instead of .xdv works:
class MyScene3(Scene): def construct(self): template = TexTemplateLibrary.ctex template.output_format=".pdf" tex = Tex(r'Hello 你好 \LaTeX', tex_template=template).scale_to_fit_width(12) self.add(tex) self.wait()
Two weeks ago dvisvgm released a repaired version, you can download the new version of dvisvgm, and then replace the old version under the LaTeX installation path.
Is this fixed now ?
Is this fixed now ?
Up till now, the hotfix of dvisvgm
(v3.1+) has not yet been updated in TeX Live 2023. As a workaround, people have to manually download/build a patched dvisvgm
executable to replace the buggy one. This hotfix is supposed to take effect in the next year's TeX Live build.
Is this fixed now ?
You can manually download the version of dvisvgm >=3.1 and configure the environment variables after installation. However, it should be noted that its environment variable must be in front of miktex or live.
Is this fixed now ?
https://dvisvgm.de/Downloads/