4

I'm trying to make a document with both English words, pinyin translation and chinese characters.

Is it possible to write the code in pinyin (or something similar) and get the corresponding characters when you compile?

Ex:

In code: jǔ -> In document: 举

or

In code: ju3 -> In document: 举

//Pinyin describes the English way of pronouncing a Chinese character. The character 举 sounds like "ju".

If this is the wrong forum please tell

  • 2
    ju3 could mean a lot of things: 举 to hold, 矩 rectangle, and so on. So I don't think your request is feasible because of this. Many different Chinese characters share the same “pinyin”. – Ruixi Zhang Jan 23 '19 at 15:53
7

This would not really be feasible, because there can be many characters with the same pronunciation (pinyin). So e.g. ma3 (or mǎ) may be 马 or 码 or 玛 ……

But perhaps you can do it the other way round: Type the Chinese characters, and the xpinyin package can annotate it with the pinyin. Here's an example from the documentation:

\documentclass{article}
\usepackage{xeCJK}
\usepackage{xpinyin}
\begin{document}
\xpinyin*{汉语拼音示例}
\end{document}

Sooner or later you'll come across characters that can have more than one pronunciation. In that case you can specify the pinyin explicitly:

\xpinyin*{小树\xpinyin{长}{zhang3}大了, 枝梢变\xpinyin{长}{chang2}了}

sample output of xpinyin

| improve this answer | |
  • 2
    +1. I'd remove the space in 小树长大了 though – Ruixi Zhang Jan 23 '19 at 15:49
  • That was my fear, but thank you anyway! – Joel Ottosson Jan 23 '19 at 16:14
  • @RuixiZhang Gah why didn't I see that. Anyway it's a long story; see thetype.com/2017/08/11606/#pinyin-size for a good discussion of typesetting pinyin, if you're interested. – LianTze Lim Jan 24 '19 at 6:04
  • 1
    That Type is Beautiful (TIB) article is what inspires me to learn more about typography. In fact, I have a proposal to support loose setting (疏排, see github.com/CTeX-org/ctex-kit/issues/387) to reproduce the 1st grade Chinese text shown in that TIB article ;). – Ruixi Zhang Jan 24 '19 at 23:54

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.