4
  • I have a English document (in UTF8) and want to place in some placed Chinese translations (single words: symbols and pinyin, which is the Latin character version).
  • Ideally, I want to use pdflatex (or lualatex) if that is possible.
  • What is the start of the art / best practice for including (little) Chinese text bits in a mainly English document using pdflatex or lualatex?
  • I am looking for a robust solution that may be feasible for some years.
  • I am also open if you recommend not to do that if this a not well supported use case for LaTeX.

This is a made-up MWE :) (I just Googled the translations).

\documentclass{article}

\begin{document}

This is an English text about apples 
(Chinese simplified/traditional: 
\SimplifiedChineseCharacter{苹} / \TraditionalChineseCharacter{蘋} 
(Pinyin: \Pinying{píng guǒ}))

\end{document}

The question may be to broad or even stupid - this is mainly due to my inexperience in this area. I am looking for some advice and some MWEs to start with.


Related


Update 1: Follow-up Question

babel: Language "pinyin"


Update 2: fontspec vs. babelfont

I have noticed that David did not use fontspec in his answer - I am not an expert in fonts but I usually see fontspec when using luatex. I found the explanation in the babel manual:

enter image description here

5

Here's a babel implementation showing English (australian) as main language, simplified and traditional Chinese, and Pinyin.

It will compile with XeLaTeX and LuaLaTeX. Though be aware that the Chinese fonts are huge and it takes the LuaTeX font loader a long time and a lot of RAM to build the cache. So long, that I can't actually compile this on my computer with LuaLaTeX. (I have a 5 year old MacBook Air with 4GB RAM running Linux. My machine just runs out of resources and kills the process.)

\documentclass{article}
\usepackage[pinyin,australian]{babel}

\babelprovide[main,import,language=Default]{australian}
\babelprovide[import,language=Chinese Simplified]{chinese-simplified}
\babelprovide[import,language=Chinese Traditional]{chinese-traditional}

\babelfont{rm}{Noto Serif}
\babelfont{sf}{Noto Sans}
\babelfont[chinese-simplified]{rm}{Noto Serif CJK SC}
\babelfont[chinese-simplified]{sf}{Noto Sans CJK SC}
\babelfont[chinese-traditional]{rm}{Noto Serif CJK TC}
\babelfont[chinese-traditional]{sf}{Noto Sans CJK TC}

\begin{document}

\section{Roman Family}

Australian English.    

\foreignlanguage{chinese-simplified}{汉语。}
\foreignlanguage{chinese-traditional}{漢語。}
\foreignlanguage{pinyin}{Pīnyīn.}
\renewcommand*{\familydefault}{\sfdefault}
\sffamily

\section{Sans Serif Family}

Australian English.

\foreignlanguage{chinese-simplified}{汉语。}
\foreignlanguage{chinese-traditional}{漢語。}
\foreignlanguage{pinyin}{Pīnyīn.}

\end{document}

I have a feeling the language= settings shouldn't be needed, but at least with my version of babel, they still are. In the future, I'd guess that this will work without explicitly specifying the language.

XeLaTeX output

Notice the difference in how the Chinese full stop is rendered in simplified and traditional Chinese.

MWE ouptput

  • That's a great answer. I will try to compile it on my computer. I need to install noto fonts first. – Dr. Manuel Kuehner Jul 15 at 4:48
  • Do you have experience with the \usepackage{xpinyin} tex.stackexchange.com/questions/471491? Would you recommend using it? – Dr. Manuel Kuehner Jul 15 at 5:08
  • 1
    @Dr.ManuelKuehner, sorry, I haven't used xpinyin. Looks like an interesting package though. – David Purton Jul 15 at 10:37
  • Hi, I can compile it now. (1) I do get the warning Package babel Warning: Unknown language 'pinyi' - do you know where I can get pinyin.ldf? (2) I had to copy the fonts into [...] AppData\Local\Programs\MiKTeX 2.9\fonts\opentype\google\noto - do you know why? I also installed them normally as system fonts but that wasn't enough apparently. Please tell me, if I should ask a new question rather than using the comment function. – Dr. Manuel Kuehner Jul 15 at 17:51
  • 1
    @Dr.ManuelKuehner, I don't know about fonts and Macs. I have the fonts installed as system fonts in the usual way on my Linux machine. For pinyin.ldf, I think it's in the cjk package. (Makre sure you spelt it right: it's pinyin, not pinyi like your error message.) – David Purton Jul 16 at 0:33
3

With pdflatex:

\documentclass{article}
\usepackage{CJKutf8}

\newcommand{\chinese}[1]{\begin{CJK}{UTF8}{bsmi}#1\end{CJK}}

\begin{document}

This is an English text about apples
(Chinese simplified/traditional: \chinese{苹}/\chinese{蘋},
Pinyin: píng guǒ)

\end{document}

enter image description here

With xelatex:

\documentclass{article}
\usepackage{xeCJK}

\setCJKmainfont{Songti SC} % use a font you have that covers Chinese

\begin{document}

This is an English text about apples
(Chinese simplified/traditional: 苹/蘋, 
Pinyin: píng guǒ)

\end{document}

enter image description here

  • 1
    +1: Thank you very much! Would a LuaTeX solution be almost identical to the XeLaTeX solution? – Dr. Manuel Kuehner Jul 14 at 16:56
  • 1
    @Dr.ManuelKuehner I'm not sure: xeCJK exploits character classes, which are not supported in LuaTeX. – egreg Jul 14 at 18:01
  • 2
    I don't think this adequately deals with differences between simplified and traditional Chinese. You need to use different font settings (or different fonts). And I notice babel has hyphenation patterns for pinyin (though I don't know how significant this is). – David Purton Jul 15 at 2:17

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.