I would like to enter a Chinese (Simplified) Characters in a TeX doc that is rendered by XeTeX and have the Pinyin transcription automatically added below the according characters. So, I only enter the Chinese characters and the Pinyin should be looked up through a library.

I have seen that ChinesePod does something similar, so I imagined that someone else must have thought of that and written something for TeX already. Do you know any tools/packages for that for TeX?

Here is a picture of how it should look like: http://cl.ly/35Lr

  • Sounds tricky: you'd need something parallel to the font map to represent the Pinyin syllables. You might have more luck at tex.stackexchange.com – Charles Stewart Nov 9 '10 at 19:59
  • Sounds like a neat idea. One tricky aspect would be dealing with line breaks automatically. – TH. Mar 31 '11 at 1:52
  • 4
    In case you don't know already, you can use the ruby package to print the pinyin under each corresponding character. However selecting the correct pinyin may not be trivial: characters often have multiple pronunciations depending on their meaning in context, e.g. 长 is cháng when meaning "long", but zhǎng when meaning "elder", "grow", "leader". – imnothere Mar 31 '11 at 2:00
  • Transcripting Chinese automatically to Pinyin is basically impossible as said by LianTze Lim. – Ma Ming Apr 2 '11 at 2:33

Another package that does transcription is the xpinyin package: http://www.ctan.org/pkg/xpinyin. You can download it with Texlive 2012's build-in update utility. You need to compile your document with XeTeX or XeLaTeX, though. Luatex etc doesn't work.

For characters with multiple pronunciations such as 重 (can be pronounced zhòng or chóng), it will mark the default pronunciation in red in the pdf. Then there is the possibility to disambiguate it by typing \xpinyin{重}{chong2} After disambiguating all such cases, one can set the colour of all multi-pronunciation items to black by specifying \xpinyinsetup{multiple={\color{black}}} in the document preamble.


Transcribing Chinese characters into Pinyin is a non-trivial problem. It requires correctly parsing the whole sentence, in order to decide where spaces occur. In some cases there may be ambiguities that would have to be resolved probabilistically or by a human operator.

Even if you leave out all the spaces (or use space between every pair of adjacent characters, which is the same thing), there may still be ambiguities in the tones or other phonological elements.

Your Answer

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