环境

环境

环境

  • 操作系统:Arch Linux x86_64
  • 主机:Windows Subsystem for Linux - Arch(2.0.9.0)
  • TEX:TinyTex

目的

我想使用Windows Fonts和 ctex 进行Chinese编写。因此我触摸了$HOME/.config/fontconfig/fonts.conf以下内容:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <dir>/mnt/c/Windows/Fonts/</dir>
</fontconfig>

运行fc-cache -fv,并fc-list显示 Windows 字体。

问题

当我运行latexmk -pdf下面的示例时:

\documentclass[fontset=windows, UTF8]{article}
\usepackage{ctex}
\begin{document}
\end{document}

报告指出error

Latexmk: This is Latexmk, John Collins, 31 Jan. 2024. Version 4.83.
No existing .aux file, so I'll make a simple one, and require run of *latex.
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex':  Reasons for rerun
Category 'other':
  Rerun of 'pdflatex' forced or previously required:
    Reason or flag: 'Initial setup'

------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex -file-line-error -halt-on-error -interaction=nonstopmode -synctex=1  -recorder  "test.tex"'
------------
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-01-22>
(/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/size10.clo)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctex.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/l3kernel/expl3.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctexhook.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctexpatch.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/fix-cm.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/ts1enc.def)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/config/ctexopts.cfg) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/CJKutf8.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/generic/iftex/ifpdf.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/generic/iftex/iftex.sty)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/inputenc.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/CJK.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/mule/MULEenc.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/CJK.enc)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/fontenc.sty)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjkpunct/CJKpunct.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjkpunct/CJKpunct.spa)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/CJKspace.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.bdg) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctexspa.def)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/zhnumber/zhnumber.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/zhnumber/zhnumber-utf8.cfg)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/tools/indentfirst.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctex-c5size.clo) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/config/ctex.cfg) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.enc) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.chr) (./test.aux) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/fd/c70rm.fd) (/home/ausosa/.TinyTeX/texmf-dist/tex/generic/ctex/zhmap/ctex-zhmap-windows.tex{/home/ausosa/.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map}{UGBK.sfd}{Unicode.sfd}) [1] (./test.aux) )
!pdfTeX error: pdflatex (file simsun.ttc): cannot open TrueType font file for reading
 ==> Fatal error occurred, no output PDF file produced!

在 wsl2 中Automount options,默认umask022,所以我不知道为什么 pdflatex 无法打开文件进行读取。

所以有什么问题?

答案1

碰巧的是,我今天早上在 wsl2 中安装了全新的 texlive 2024 预测试,因此以下绝对是我需要做的唯一更改,以便您的示例运行并产生

在此处输入图片描述

只需修改

/usr/local/texlive/2024/texmf.cnf

(或者更可能2023在你安装 texlive 的任何地方)添加设置,以便它查找 windows 字体目录

我的文件现在看起来像

% (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
%
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
%
TTFONTS = $TEXMFDOTDIR;$TEXMF/fonts/{truetype,opentype}//;$OSFONTDIR//:/mnt/c/windows/fonts

OPENTYPEFONTS = $TEXMFDOTDIR;$TEXMF/fonts/{opentype,truetype}//;$OSFONTDIR//:/mnt/c/windows/fonts

只需添加:/mnt/c/windows/fonts从中复制的两个设置 /usr/local/texlive/2024/texmf-dist/web2c/texmf.cnf

相关内容