CTeX-org / forum

A temporarily alternate forum of `bbs.ctex.org`
https://t.me/chinesetex
Apache License 2.0
210 stars 16 forks source link

linux和windows下伪粗效果不统一 #281

Closed ytskuh closed 1 year ago

ytskuh commented 1 year ago

检查

编译环境

描述问题

学校提供了latex论文模板。该模板应该是为windows系统下设计的,未指定fontset参数。在linux下会默认使用Fandol字库而导致使用字体不符合要求。添加fontset=windows后,虽然能够得到相同的字体(SimSun, SimHei),但无法显示粗体。windows下似乎自动使用了伪粗,但linux下不行。添加AutoFakeBold=2参数后,能得到大体上相同的结果,但细节依然有差异。

虽然从效果上来看,linux下显式地使用伪粗似乎更好(无锯齿形),但是这毕竟是一个问题——不同平台无法实现相同的效果。并且,我无法得知windows下自动的伪粗究竟使用的是什么参数。

最小工作示例(MWE)

windows版(原本):

\documentclass[UTF8,a4paper,12pt]{ctexart}
\begin{document}
\songti\zihao{1} \textbf{模板}
\end{document}

image

为实现相同字体,Linux下的修改版:

\documentclass[UTF8,a4paper,12pt, fontset=windows, AutoFakeBold=2]{ctexart}
\begin{document}
\songti\zihao{1} \textbf{模板}
\end{document}

image

muzimuzhi commented 1 year ago

windows版(原本):

\documentclass[UTF8,a4paper,12pt]{ctexart}
\begin{document}
\songti\zihao{1} \textbf{模板}
\end{document}
ytskuh commented 1 year ago

用的xelatex 确认是。我是请求他人帮我尝试的。短时间内不能上传log。但学校提供的模板里pdf的效果一模一样(锯齿状伪粗)。并且他应该没有修改过什么配置。

muzimuzhi commented 1 year ago

但学校提供的模板里pdf的效果一模一样(锯齿状伪粗)。并且他应该没有修改过什么配置。

不,这种稍微错开多次排印的伪粗,不是 ctexart 默认会使用的。我在 GitHub Actions 里做了测试,见 https://github.com/muzimuzhi/hello-github-actions/pull/10 。Windows Server 2022 + TeX Live 2023 下,xelatex 编译你的例子得到的是正常的无加粗的 宋体/SimSun(可以从这里下载 artifacts 查看 PDF),并伴随 warning

LaTeX Font Warning: Font shape `TU/SimSun(1)/b/n' undefined
(Font)              using `TU/SimSun(1)/m/n' instead on input line 3.

请务必检查哪里改了,比如有没有加载一个自定义的 ctex.cfgxeCJK.cfg。如果安装 TeX Live 2023 后没有手动改过发行版安装目录下的文件,可以在 log 里找找有没有特别的路径。上传完整 log 文件可能会有帮助,只是可能。

sikouhjw commented 1 year ago

我认为你提供的信息是错的,以下是复现条件、代码和效果:

\documentclass{article}
\usepackage[scheme=plain]{ctex}
\begin{document}
\songti\zihao{1}\bfseries 模板
\end{document}
\documentclass[AutoFakeBold=2]{ctexart}
\begin{document}
\songti\zihao{1} \textbf{模板}
\end{document}

可以发现,只跟引擎有关,请你确保你所说的『用的xelatex』是你亲眼看见、用命令行编译、能提供 log 文件的结果,否则不能作为证明。

ytskuh commented 1 year ago

理解。看来应该是用pdflatex编译才产生了这种效果。为给出了错误的信息而抱歉。最后请教一下,如何用pdflatex编译?我用latexmk -pdflatexpdflatex均会报错,显示

!pdfTeX error: pdflatex (file simsun.ttc): cannot open TrueType font file for r
eading
sikouhjw commented 1 year ago

理解。看来应该是用pdflatex编译才产生了这种效果。为给出了错误的信息而抱歉。最后请教一下,如何用pdflatex编译?我用latexmk -pdflatexpdflatex均会报错,显示

!pdfTeX error: pdflatex (file simsun.ttc): cannot open TrueType font file for r
eading

你大概率是用 Linux 环境编译的,请你提供『完整』的信息,并尝试自行检索。