7

I want to type Chinese with latex. I have new installed mac OS system (English). I use texshop as IDE. And now I keep getting simsun or simhei not found error. I guess these fonts are windows fonts. Could anyone summarize how to prepare the Chinese fonts on a English mac system?

\documentclass[UTF8]{ctexart}
\begin{document}
文章内容。
\end{document}

Error log:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
/usr/local/texlive/2014/texmf-dist/tex/latex/ctex/fontset/ctex-xecjk-winfonts.d
ef:5: fontspec error: "font-not-found"
! 
! The font "SimHei" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.5   {SimSun}
11

ctex bundle use Chinese fonts for Windows by default. You can use the fonts installed in Mac.

% !TEX program = XeLaTeX
% !TEX encoding = UTF-8
\documentclass[UTF8,nofonts]{ctexart}
\setCJKmainfont[BoldFont=STHeiti,ItalicFont=STKaiti]{STSong}
\setCJKsansfont[BoldFont=STHeiti]{STXihei}
\setCJKmonofont{STFangsong}

\begin{document}
文章内容。
\end{document}

There is nothing much to summerize, just change the fonts following the xeCJK manual. On Mac OS X, STSong and other SinoType fonts are preinstlled.

Alternatively, you can also use free Fandol fonts for Chinese documents, which are preinstlled in latest TeX Live (MacTeX).

% !TEX program = XeLaTeX
% !TEX encoding = UTF-8
\documentclass[UTF8,nofonts]{ctexart}
\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}
文章内容。
\end{document}

We plan to release a new version of ctex bundle later this year, which provides more font sets for those Mac OS X and Linux users.

  • 1
    Change % !TEX encoding = UTF-8 to % !TEX encoding = UTF-8 Unicode works. – Daniel Jul 28 '14 at 22:00
  • And it seems that the second example does not work in traditional Chinese, the first example works for both. – Daniel Jul 28 '14 at 22:07
  • @Daniel: Both examples use Chinese fonts designed in Mainland China. You can of course use any fonts you have. – Leo Liu Jul 29 '14 at 5:28
  • Hi! It would be useful to know whether there is a chance that Mac versions of TeXlive will include what appear to the Debian/Fedora standard WenQuanYi Zen Hei fonts. Then people can use the same instructions for both; right now one has to either download them (from an all-Chinese page) or use two different sets (or so it appears to me). – kcrisman Dec 5 '14 at 15:02
  • @kcrisman: 1. WenQuanYi fonts are poorly designed. 2. WenQuanYi fonts are designed for screen only, while TeX is mainly for typesetting. 3. Fandol fonts are far better protable fonts for TeX. 4. For screen fonts, there are Source Han Sans fonts. – Leo Liu Dec 5 '14 at 15:12
3

According to this blog, the following tex file is work for me on my MAC with the TeXShop.

\documentclass{article}

\usepackage{CJKutf8}

\begin{document}
\begin{CJK}{UTF8}{gbsn}
文章内容。

Contents of the article.
\end{CJK}
\end{document}
  • This solution does not work for me, OS X 10.8.5. – SigmaX Dec 15 '14 at 0:59
  • Thanks, this works for me, Mojave 10.14.4. – wind2412 Apr 11 at 4:04
2

Things are much improved for the current version of ctex (from TL2015 and later).

If you use \documentclass{ctexart} and compile it with XeLaTeX or LuaLaTeX, the package will detect the OS it's running on, and use Chinese fonts pre-installed on the system. If it doesn't get it right, you can pass in the fontset option to help it along:

\documentclass[fontset=ubuntu]{ctexart} % Uses the Arphic fonts
\documentclass[fontset=mac]{ctexart}
\documentclass[fontset=windows]{ctexart}

And if you have the relevant fonts installed on your OS:

\documentclass[fontset=adobe]{ctexart}
\documentclass[fontset=fandol]{ctexart}

The ctex bundle actually includes the Fandol fonts, but this is installed by default in the TEXMF tree only, not in the operating system's fonts. Therefore you may run into problems if you use XeLaTeX with the fandol option, because XeLaTeX doesn't support/use fontconfig. However! all is well if you compile with LuaLaTeX.

For all these options, the most important font families \songti, \heiti, \kaishu are available. \fangsong is unavailable in ubuntu, while windows has extra \youyuan and \lishu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.