Open liuanhua110 opened 2 months ago
解决方案:
sudo mkdir -p texmf-local/fonts/truetype/msfonts
,然后cp进去了cd /usr/local/texlive/2024/
context --generate
mtxrun --script fonts --reload --force
/usr/local/texlive/2024/bin/x86_64-linux/pdflatex -interaction=batchmode -file-line-error merge_translate_zh.tex
即可成功生成pdf,如果有别的问题,可以看看log
其实直接把这个字体放在文件夹目录下也能解决
解决方案:
- 找到texlive的安装目录,对于我来说是在/usr/local/texlive/2024
- 在安装目录中的一个tex文档下其实官方给了解决方案,但是对于我来说没有work,解决方案在这个文档中 texmf-dist/doc/context/third/context-notes-zh-cn/src/03.tex
- 对于我来说,我把内3个字体,simhei.ttf, simkai.ttf,simsun.ttc复制到了/usr/local/texlive/2024/texmf-dist/fonts/truetype
- 添加这三个到/usr/local/texlive/2024/texmf-dist/ls-R中
- 按照03.tex的说法也执行了一遍(我觉得可以去掉),先是mkdir了下
sudo mkdir -p texmf-local/fonts/truetype/msfonts
,然后cp进去了- 最后加载字体
cd /usr/local/texlive/2024/
context --generate
mtxrun --script fonts --reload --force
- 再去文件夹里面执行
/usr/local/texlive/2024/bin/x86_64-linux/pdflatex -interaction=batchmode -file-line-error merge_translate_zh.tex
即可成功生成pdf,如果有别的问题,可以看看log
这里的描述是正确的:
但是,可以进一步简化,以我的环境(Ubuntu 22.04.4 LTS,texlive 2024)为例:
# Install Chinese fonts in the TeX Directory Structure (TDS):
$ mkdir -p $(kpsewhich -var-value=TEXMFHOME)/fonts/truetype
# $HOME/.local/share/fonts/windows 是我的windows字体目录,根据自己的情况调整:
$ ln -s $HOME/.local/share/fonts/windows $(kpsewhich -var-value=TEXMFHOME)/fonts/truetype
$ texhash $(kpsewhich -var-value=TEXMFHOME)
# Check
$ fc-match simsun
simsun.ttc: "SimSun" "Regular"
$ kpsewhich simsun.ttc
/home/werner/texmf/fonts/truetype/windows/simsun.ttc
Test for pdflatex, xelatex and lualatex:
$ cat ctex.tex
\documentclass{article}
\usepackage[UTF8, fontset=windows]{ctex}
\begin{document}
这是一个使用 SimSun 字体的中文测试。
\end{document}
$ pdflatex ctex.tex This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode (./ctex.tex LaTeX2e <2024-06-01> patch level 2 L3 programming layer <2024-08-30> (/opt/texlive/2024/texmf-dist/tex/latex/base/article.cls Document Class: article 2024/02/08 v1.4n Standard LaTeX document class (/opt/texlive/2024/texmf-dist/tex/latex/base/size10.clo)) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/ctex.sty (/opt/texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty (/opt/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/ctexhook.sty) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/ctexpatch.sty) (/opt/texlive/2024/texmf-dist/tex/latex/base/fix-cm.sty (/opt/texlive/2024/texmf-dist/tex/latex/base/ts1enc.def)) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/config/ctexopts.cfg) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def (/opt/texlive/2024/texmf-dist/tex/latex/cjk/texinput/CJKutf8.sty (/opt/texlive/2024/texmf-dist/tex/generic/iftex/ifpdf.sty (/opt/texlive/2024/texmf-dist/tex/generic/iftex/iftex.sty)) (/opt/texlive/2024/texmf-dist/tex/latex/base/inputenc.sty) (/opt/texlive/2024/texmf-dist/tex/latex/cjk/texinput/CJK.sty (/opt/texlive/2024/texmf-dist/tex/latex/cjk/texinput/mule/MULEenc.sty) (/opt/texlive/2024/texmf-dist/tex/latex/cjk/texinput/CJK.enc)) (/opt/texlive/2024/texmf-dist/tex/latex/base/fontenc.sty)) (/opt/texlive/2024/texmf-dist/tex/latex/cjkpunct/CJKpunct.sty (/opt/texlive/2024/texmf-dist/tex/latex/cjkpunct/CJKpunct.spa)) (/opt/texlive/2024/texmf-dist/tex/latex/cjk/texinput/CJKspace.sty) (/opt/texlive/2024/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.bdg) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/ctexspa.def)) (/opt/texlive/2024/texmf-dist/tex/latex/zhnumber/zhnumber.sty (/opt/texlive/2024/texmf-dist/tex/latex/zhnumber/zhnumber-utf8.cfg)) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def (/opt/texlive/2024/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg)) (/opt/texlive/2024/texmf-dist/tex/latex/tools/indentfirst.sty) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/ctex-c5size.clo) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def)) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/config/ctex.cfg) (/opt/texlive/2024/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.enc) (/opt/texlive/2024/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.chr) No file ctex.aux. (/opt/texlive/2024/texmf-dist/tex/latex/ctex/fd/c70rm.fd) (/opt/texlive/2024/texmf-dist/tex/generic/ctex/zhmap/ctex-zhmap-windows.tex{/op t/texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}{UGBK.sfd}{Unicode. sfd}) [1] (./ctex.aux) )</home/werner/texmf/fonts/truetype/windows/simsun.ttc>< /home/werner/texmf/fonts/truetype/windows/simsun.ttc></home/werner/texmf/fonts/ truetype/windows/simsun.ttc></home/werner/texmf/fonts/truetype/windows/simsun.t tc></home/werner/texmf/fonts/truetype/windows/simsun.ttc></home/werner/texmf/fo nts/truetype/windows/simsun.ttc></home/werner/texmf/fonts/truetype/windows/sims un.ttc></home/werner/texmf/fonts/truetype/windows/simsun.ttc></home/werner/texm f/fonts/truetype/windows/simsun.ttc></home/werner/texmf/fonts/truetype/windows/ simsun.ttc></home/werner/texmf/fonts/truetype/windows/simsun.ttc></opt/texlive/ 2024/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb> Output written on ctex.pdf (1 page, 60653 bytes). Transcript written on ctex.log.
2. xelatex:
werner@x13dai-t:~/test$ cat xelatex.tex \documentclass{article} \usepackage{xeCJK} \setCJKmainfont{SimSun} \begin{document} 这是一个使用 Windows SimSun 字体的中文测试。 \end{document}
werner@x13dai-t:~/test$ xelatex xelatex.tex This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex) restricted \write18 enabled. entering extended mode (./xelatex.tex LaTeX2e <2024-06-01> patch level 2 L3 programming layer <2024-08-30> (/opt/texlive/2024/texmf-dist/tex/latex/base/article.cls Document Class: article 2024/02/08 v1.4n Standard LaTeX document class (/opt/texlive/2024/texmf-dist/tex/latex/base/size10.clo)) (/opt/texlive/2024/texmf-dist/tex/xelatex/xecjk/xeCJK.sty (/opt/texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty (/opt/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-xetex.def)) (/opt/texlive/2024/texmf-dist/tex/latex/ctex/ctexhook.sty) (/opt/texlive/2024/texmf-dist/tex/latex/l3packages/xtemplate/xtemplate.sty) (/opt/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty (/opt/texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty) (/opt/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty (/opt/texlive/2024/texmf-dist/tex/latex/base/fontenc.sty) (/opt/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg))) (/opt/texlive/2024/texmf-dist/tex/xelatex/xecjk/xeCJK.cfg)) No file xelatex.aux. (/opt/texlive/2024/texmf-dist/tex/latex/base/ts1cmr.fd) [1] (./xelatex.aux) ) Output written on xelatex.pdf (1 page). Transcript written on xelatex.log. werner@x13dai-t:~/test$ grep -i simsun xelatex.log (fontspec) Could not resolve font "SimSun/BI" (it probably doesn't (fontspec) Could not resolve font "SimSun/B" (it probably doesn't (fontspec) Could not resolve font "SimSun/I" (it probably doesn't (fontspec) Font family 'SimSun(0)' created for font 'SimSun' with (fontspec) <->"SimSun/OT:script=hani;language=dflt;"
3. lualatex:
werner@x13dai-t:~/test$ cat lualatex.tex \documentclass{article} \usepackage{luatexja-fontspec} \setmainjfont{SimSun}
\begin{document} 这是一个使用 Windows SimSun 字体的中文测试。 \end{document}
werner@x13dai-t:~/test$ lualatex lualatex.tex This is LuaHBTeX, Version 1.18.0 (TeX Live 2024) restricted system commands enabled. (./lualatex.tex LaTeX2e <2024-06-01> patch level 2 L3 programming layer <2024-08-30> (/opt/texlive/2024/texmf-dist/tex/latex/base/article.cls Document Class: article 2024/02/08 v1.4n Standard LaTeX document class (/opt/texlive/2024/texmf-dist/tex/latex/base/size10.clo)) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/addons/luatexja-fontspec.sty (/opt/texlive/2024/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty (/opt/texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty (/opt/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-luatex.def))) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/luatexja.sty (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/luatexja-core.sty (/opt/texlive/2024/texmf-dist/tex/generic/infwarerr/infwarerr.sty) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexbase/luatexbase.sty (/opt/texlive/2024/texmf-dist/tex/luatex/ctablestack/ctablestack.sty)) (/opt/texlive/2024/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty) (/opt/texlive/2024/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty (/opt/texlive/2024/texmf-dist/tex/generic/iftex/iftex.sty)) (/opt/texlive/2024/texmf-dist/tex/latex/xkeyval/xkeyval.sty (/opt/texlive/2024/texmf-dist/tex/generic/xkeyval/xkeyval.tex (/opt/texlive/2024/texmf-dist/tex/generic/xkeyval/xkvutils.tex (/opt/texlive/2024/texmf-dist/tex/generic/xkeyval/keyval.tex)))) (/opt/texlive/2024/texmf-dist/tex/latex/etoolbox/etoolbox.sty) (/opt/texlive/2024/texmf-dist/tex/latex/everyhook/everyhook.sty (/opt/texlive/2024/texmf-dist/tex/latex/svn-prov/svn-prov.sty)) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/ltj-base.sty) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/ltj-latex.sty (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/patches/lltjfont.sty (/opt/texlive/2024/texmf-dist/tex/latex/base/tuenc.def)) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/patches/lltjdefs.sty (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/jfm-ujisv.lua) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/jfm-ujis.lua)) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/patches/lltjcore.sty) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/patches/lltjp-atbegshi.sty) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/patches/lltjp-geometry.sty (/opt/texlive/2024/texmf-dist/tex/generic/iftex/ifluatex.sty)))) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/luatexja-compat.sty)) (/opt/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty (/opt/texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty) (/opt/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty (/opt/texlive/2024/texmf-dist/tex/latex/base/fontenc.sty) (/opt/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg))) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/patches/lltjp-fontspec.sty) (/opt/texlive/2024/texmf-dist/tex/luatex/luatexja/addons/luatexja-fontspec-29e. sty)) No file lualatex.aux. (/opt/texlive/2024/texmf-dist/tex/latex/base/ts1cmr.fd) [1{/opt/texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./lualatex.aux)) 787 words of node memory still in use: 7 hlist, 1 vlist, 4 rule, 2 glue, 3 kern, 1 glyph, 129 attribute, 48 glue_sp ec, 20 attribute_list, 1 write, 9 user_defined nodes avail lists: 1:13,2:1063,3:9,4:17,5:23,6:2,7:118,8:1,9:46,11:4 </opt/texlive/2024/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf></ home/werner/Public/xdgbds/local/share/fonts/windows/simsun.ttc> Output written on lualatex.pdf (1 page, 12450 bytes). Transcript written on lualatex.log.
# Comparison of LaTeX Engines' Font Handling
| Feature | XeLaTeX | LuaLaTeX | pdfLaTeX |
|---------|:-------:|:--------:|:--------:|
| System fonts | ✓ | ✓ | ✗ |
| TeX Live fonts | ✓ | ✓ | ✓ |
| Unicode support | Native | Native | Limited |
| Font technology | OpenType, TrueType | OpenType, TrueType | Type1, limited TrueType |
| CJK support | Native | Native | Requires CJK package |
| Font selection | fontspec | fontspec | NFSS |
## Key points:
- XeLaTeX and LuaLaTeX can use both system fonts and TeX Live fonts.
- pdfLaTeX is limited to fonts in the TeX Directory Structure (TDS).
- XeLaTeX and LuaLaTeX offer superior Unicode and CJK support.
- pdfLaTeX requires additional packages for extended language support.
Installation Method | 安装方法与平台
Others (Please Describe)
Version | 版本
Latest | 最新版
OS | 操作系统
Linux
Describe the bug | 简述
由于最为关键的转化PDF编译失败, 将根据报错信息修正tex源文件并重试, 当前报错的latex代码处于第[-1]行 ...[Bug] 看merge_translate_zh.log发现是因为缺少字体,!pdfTeX error: pdflatex (file simhei.ttf): cannot open TrueType font file for reading
Screen Shot | 有帮助的截图
如上所示
Terminal Traceback & Material to Help Reproduce Bugs | 终端traceback(如有) + 帮助我们复现的测试材料样本(如有)
No response