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

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

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

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

\documentclass[UTF8,nofonts]{ctexart}
\usepackage{xeCJK}
\title{中文测试}
\author{测试}
\date{\today}
% 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}
\begin{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

转载于:https://www.cnblogs.com/docnan/p/7081500.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值