Mac, Linux中统一配置Latex中文字体

Mac, Linux中统一配置Latex中文字体

对于中文的latex文档,在Linux下一般可以使用系统自带的开源字体:文泉驿(WenQuanYi)来实现,即如下的最小例子,通过xelatex命令来编译即可生成中文文档。

documentclass[UTF8,nofonts]{ctexart}
usepackage{xeCJK}
	itle{中文测试}
author{测试}
date{	oday}
% use buildin Chinese font in linux
setCJKmainfont[BoldFont={WenQuanYi Micro Hei/Bold}]{WenQuanYi Micro Hei}
egin{document}large
section{中文}
中文测试,中文测试,中文测试。
end{document}

而在Mac下并没有文泉驿字体,但是却有其它的中文字体,有没有同时兼容Linux和Mac,而且不用安装额外字体的解决方案呢?
从网上搜到了解决方法,更换为通用的字体即可[1](可叹的是,给出解决方案的竟然是老外,国内的百度没搜到有用的解决方案):

documentclass[UTF8,nofonts]{ctexart}
usepackage{xeCJK}
	itle{中文测试}
author{测试}
date{	oday}
% use buildin Chinese font in linux and Mac
setCJKmainfont[BoldFont=FandolSong-Bold.otf,ItalicFont=FandolKai-Regular.otf]{FandolSong-Regular.otf}
setCJKsansfont[BoldFont=FandolHei-Bold.otf]{FandolHei-Regular.otf}
setCJKmonofont{FandolFang-Regular.otf}
egin{document}large
section{中文}
中文测试,中文测试,中文测试。
end{document}

经过测试,这种设置在Linux Fedora25的英文环境也可以通过编译,成功生成中文的pdf文档。

参考:
[1]https://tex.stackexchange.com/questions/215564/what-chinese-fonts-can-i-rely-on-to-be-in-mac-and-linux