With the package \pinyin, it is possible to write pinyin using commands such as \bu4. This package produces much better tone marks than are provided by \', \v, etc.

The package \pinyin includes all of the pinyin for full words, as well as \a and \o (because by themselves these can be words), however, I need to typeset the remaining finals individually:

ē é ě è ī í ǐ ì ū ú ǔ ù ǖ ǘ ǚ ǜ

It is rare for these to appear on their own, hence, I have not been able to locate any commands which will print them, provided by the pinyin package, so I think the authors left that out.

I have found a copy of the source code on CTAN, however, it does not appear to be using LaTeX code to define things. I believe somewhere in this code much of the answer, but it is filled with these strange @ and #'s:

  \ifcase #4
    \or\py@macron #1{.3}\or\py@acute #1\or\py@hacek #1\or\py@grave #1\or #1
  \py@kern #1{#3}}

\def\py@a{\py@@ a}
\def\py@A{\py@@ A}

\def\py@e{\py@@ e}
\def\py@E{\py@@ E}

  \ifcase #3
    \or\py@macron\i{.3}\or\py@acute\i\or\py@hacek\i\or\py@grave\i\or i
  \py@kern i{#2}}
\def\py@I{\py@@ I}

\def\py@o{\py@@ o}
\def\py@O{\py@@ O}

\def\py@u{\py@@ u}
\def\py@U{\py@@ U}

How can I replicate the results of the pinyin package, but only displaying the finals (ending vowels) on their own?

Update: Just to clarify, I don't need all of the finals (i.e. -ue, -ing), as I can typeset those with a combination of letters.

  • 1
    \def\LOL@code_with#! :)
    – Count Zero
    Nov 16, 2011 at 13:16

2 Answers 2


1. Quick solution

First, let me answer your question in short: feel free to use \v{e}, \'\i and \={\"u} to typeset ě, í and ǖ. You don't need pinyin package for this. And pinyin package itself is just a shortening for these accents.

2. A better implementation

Honestly, pinyin package on CTAN is not at all well implemented. It is dangerous to redefine, for example, \mu as pinyin since it is a Greek letter!

Here is a much better implementation of pinyin in Chinese, by 蒋 (ID: pointer) from CTeX forum, a Chinese TeX community:

\usepackage[UTF8]{ctex}% for Chinese, but not necessary for Pinyin

% Definitions of Pinyin
  \if a#1 10\else
  \if o#1 9\else
  \if e#1 8\else
  \if i#1 7\else
  \if u#1 6\else
  \if v#1 5\else
  \if A#1 4\else
  \if O#1 3\else
  \if E#1 2\fi\fi\fi\fi\fi\fi\fi\fi\fi0


% Usage:
% \pinyin{Hao3hao3\ xue2xi2} (好好学习)
  % scan
  \ifnum 0 < 0\py@char
    \py@first \py@tuneat\py@tuneletter\py@tune \py@last\kern -4sp\kern 4sp{}\py@init
    \ifnum\py@yunpriv\py@char > \py@yunpriv\py@tuneletter
      \edef\py@last{\py@last\if v\py@char\"u\else\py@char\fi}%
    \edef\py@befirst{\py@befirst\if v\py@char\"u\else\py@char\fi}%

\let\py@macron \=
\let\py@acute \'
\let\py@hacek \v
\let\py@grave \`

%% \py@tuneat{Letter}{tune}
  \if v#1%
    \py@tune@v #2%
  \if i#1%
    \py@tune@i #2%
      \or\py@macron #1\or\py@acute #1\or\py@hacek #1\or\py@grave #1\else #1%

    \dimen@ii 1ex%
    \fontdimen5\font 1.1ex%
    \fontdimen5\font .6ex%
      \or\py@macron u\or\py@acute u\or\py@hacek u\or\py@grave u\else u%

    \or\py@macron \i\or\py@acute \i\or\py@hacek \i\or\py@grave \i\else i%
% End of pinyin


女人 \pinyin{nv3ren2}

木头 \pinyin{mu4tou5} --- $\mu$ % no conflicts

韵母 \pinyin{a1\ i3\ u4\ v2}

啊\pinyin{A1} 哦\pinyin{O4} 恶心吧\pinyin{E3xin1\ ba5}


好好学习\pinyin{Hao3hao3\ xue2xi2}


enter image description here

3. My final advice

Nowadays, we sugguest XeTeX with xeCJK for CJK typesetting. XeTeX is a Unicode TeX engine, then you can use ě, í and ǖ in the source code directly, with help of a good GUI input pad. The example above can be changed to:

% XeLaTeX needed

女人 nǚrén

木头 mùtou --- $\mu$

韵母 ā ǐ ù ǘ

Don't use pdfLaTeX or latex with CJK to compile this. Since some of the vowels are handled by CJK but the fonts are full-width (badly designed), the result may be strange without XeTeX. Of course, if you don't need CJK ideograms, you can use inputenc package for the pinyin vowels.

4. A new xpinyin package is available

Qing Lee (李清) wrote a new xpinyin package to typesetting pinyin semi-automatically.

\setmainfont{CMU Serif}

  • Some Chinese fonts need to be installed in your OS to compile the examples. I'm sorry. If you use windows, I think everything should be OK.
    – Leo Liu
    Nov 17, 2011 at 4:33
  • For your solution no.2, is the pinyin implementation by 蒋 currently included as part of any packages?
    – imnothere
    Nov 17, 2011 at 8:11
  • @LianTzeLim: No. It is a good implementation and I like it. But I guess I have no right to post his code to CTAN before asking him. BTW, there're still some small problems with his solution in different fonts.
    – Leo Liu
    Nov 17, 2011 at 8:39
  • All of your solutions worked well. I'll look into installing XeTeX. My document already has the marks in place just like you wrote in part 3; this will save me lots of trouble in trying to convert it.
    – Village
    Nov 18, 2011 at 23:14
  • 1
    @AndreasT: I fixed the problem for the usual cases. It won't work for wrong pinyins like .
    – Leo Liu
    May 30, 2013 at 14:25

Well I have absolutly no knowledge of cjk-scripts and I have no idea what you mean by "finals" etc. But looking at the code I would say to get something similar to \bu4 you should do this:



\bu4 % defined with \py@DRC{\bu}{b\py@ ub{}#1} line 383

\py@DRC{\be}{b\py@ eb{}#1} %use e instead of u

Btw: The code of pinyin is normal tex. In a sty like this all the @ are normal letters like p or q and can be used in command names. The #1 are for arguments of commands.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .