3

I am trying to use some Chinese characters in my Latex document(But it is not entirely in Chinese) and this is the website that I came across. According to the author, all I need is to use ctex package, but when I copy paste the example code in his website it failed to compile with the error message critical package ctex error:ctex fontset"fandol" is unavailable in current I wonder what went wrong? And if his method is incorrect, I wonder if there is another way that allow me to type Chinese successfuly. (I can not change the documentclass as I am trying to use a poster theme template and the documentclass ,I assume, is predefined.)

MWE:

\documentclass[UTF8]{ctexart}
\usepackage[T1]{fontenc}

\begin{document}
你好,这是一个测试文档。
\end{document}

enter image description here edit: include the error message and picture edit2: uploaded the wrong one. inlcude the correct picture[!

7
  • your example works for me with pdflatex + windows + a current texlive. May 22 '20 at 14:04
  • added the picture. It is not compilable on my Macbook. Do you think it has anything to do with font selection on my local computer? But it also failed to compile on overleaf.
    – jxhyc
    May 22 '20 at 14:11
  • You are using xelatex, so remove \usepackage[T1]{fontenc}. Beside this: "warning" is a warning/info not an error. Check if the output is okay. May 22 '20 at 14:23
  • Sorry I uploaded the wrong picture. You are right it is compilable using XeLaTex, But when I tried to compile it on LaTex, the compilation was not successful. Would you be kind enough to point out what went wrong? I am not sure my other code, which was written with Latex in mind, can be compiled in XeLaTex without any problem.
    – jxhyc
    May 22 '20 at 14:59
  • try to set another fontset, see tex.stackexchange.com/a/284933/2388 May 22 '20 at 15:26
2

You cannot use pdflatex to compile Chinese documents that specify fandol fonts because

使用Fandol中文字体,不支持pdfLaTeX。

Using Fandol Chinese fonts, pdfLaTeX is not supported.

Reference texdoc ctex, sec 4.3中文字库

You may need to install other Chinese fonts, such as: Source Han Serif

2
  • I don’t understand when did I specify that
    – jxhyc
    May 22 '20 at 15:21
  • @jxhyc If a fontset value is not specified, the CTEX macro set will automatically detect the operating system used by the user and configure the appropriate font. So Overleaf specifies by default that fandol, Mac OS X compiler Chinese is not available under pdflatex.
    – sikouhjw
    May 22 '20 at 15:25
0

This works for me

if your content goes like this

\documentclass{article}  
\usepackage[UTF8]{ctex}  
\begin{document}  
    中文输入  
\end{document}

Just add this line %!TEX program = xelatex to the top of your TeX file like this:

%!TEX program = xelatex
\documentclass{article}  
\usepackage[UTF8]{ctex}  
\begin{document}  
    中文输入  
\end{document}

Thanks to the blog: http://fangda.me/2018/10/23/Latex%E5%8A%A0%E5%85%A5%E4%B8%AD%E6%96%87%E5%8C%85%E7%9A%84%E9%94%99%E8%AF%AF%E5%A4%84%E7%90%86/

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.