中文設(shè)置:
在安裝環(huán)境文件 manim/constants.py中設(shè)置TEX_USE_CTEX = True
如果還是文字或者中文輸出有問題:
zhihu
更多中文設(shè)置在文件lib/python3.7/site-packages/manimlib/ctex_template.tex中
比如可以添加\usepackage{xeCJK}
我們可以提前編寫一個xxx.tex文件,然后使用命令xelatex xxx.tex 進(jìn)行編譯出pdf進(jìn)行測試
windows下的安裝:
首先安裝: choco ,注意是在管理員下打開powershell.
安裝cairo: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo
choco install gtk-runtime
choco install sox.portable
choco install ffmpeg
# choco install miktex
pip install pyreadline
也可手動安裝CTEX (不推薦)
請直接安裝Texlive !
在國內(nèi)源https://mirror.bjtu.edu.cn/CTAN/systems/texlive/
進(jìn)行下載:
下載texlive(2020.4.6)
下載dvisvgm并手動添加至環(huán)境變量
Ubuntu下的安裝:
Install system libraries:
sudo apt install sox ffmpeg libcairo2 libcairo2-dev
Install Latex distribution:(Recommend)
sudo apt install texlive-full
Install manim via pypi:
pip install manimlib
或者手動安裝Latex:(強(qiáng)烈不!推!薦!)
1.使用apt-cache search latex, 可以看到許多包。
選擇安裝texlive-latex-base, 它的描述是:Tex Live: Basic LaTex packages.
sudo apt-get install texlive-latex-base
2.這樣就安裝好Latex了,可以直接使用。 但編譯中文時,由于沒有安裝CJK中文環(huán)境,會提示找不到CJK包。
apt-cache search cjk, 有許多關(guān)于CJK 環(huán)境的包。
選擇安裝latex-cjk-all, 它的描述是:Installs all LaTex CJK packages.
sudo apt install latex-cjk-all
這樣就可以使用中文環(huán)境了。
3.有些.sty文件可能沒有安裝,例如:lastpage.sty. 這個時候不要到網(wǎng)絡(luò)上去詢問是因?yàn)槭裁矗?Latex的輸出錯誤信息已經(jīng)很明顯了。
使用下面的命令來查找相應(yīng)的包:
apt-cache search lastpage (注意不要加.sty文件后綴)
可以看到需要下面的包,以及對這個包的描述:
texlive-latex-extra - TeX Live: LaTeX supplementary packages
選擇安裝即可:
sudo apt-get install texlive-latex-extra
完成上面的這三步,就可以完全滿足我平時的應(yīng)用需求了。 如果以后需要使用到新的包,可以使用上面第三步的方法來查找相應(yīng)的安裝包,并選擇安裝即可。
4.sudo apt-get install texmaker
安裝texmaker程序,它是一個圖形化界面的Tex書寫,編譯,生成,預(yù)覽集合為一體的程序。 與Windows操作系統(tǒng)中的WinTex界面很相似。
//為了使用xelatex
5.sudo apt-get install texlive-xetex
Texlive-publishers包也可以安裝一下, support for publishers, theses, standards, conferences, etc.
6.下sudo apt-get install texlive-publishers
使用apt-cache show texlive-publishers命令可以看到它所支持的CTAN包的信息。
ubuntu下中文生僻字處理:
https://blog.csdn.net/up_com/article/details/51099928
看這個吧
導(dǎo)入windows中的字體
ubuntu自帶的中文字體較少,可以選擇導(dǎo)入Windows里的字體。
在windows系統(tǒng)中找到字體文件,一般位于C:\windows\fonts, 再搬到ubuntu下的/usr/share/fonts/(當(dāng)然,可以不必全部搬過來),可以重命名其為winfonts,再打開終端執(zhí)行以下命令
cd /usr/share/fonts/winfonts
sudo mkfontscale
sudo mkfontdir
sudo fc-cache -fv
查看字體是否存在了: fc-list :lang=zh | grep '宋體'
以上就完成了,用xelatex驗(yàn)證下:
\documentclass[preview]{standalone}
\usepackage[UTF8]{ctex}
\usepackage{xeCJK}
\setCJKmainfont{SimSun}
\begin{document}
焜焜焜焜焜焜
\end{document}