# Hyphenation for Chinese pinyin

Using XeLaTeX with polyglossia, I’m typesetting a document that includes Chinese pinyin: not the whole text, but still a fair bit, so I want to avoid manually providing rules for hyphenation.

Unfortunately, polyglossia doesn’t seem to offer Chinese pinyin support. Is there a package that provides pinyin hyphenation (maybe triggered by a command like \pinyin{text in pinyin})?

The documentation of the xeCJK package (which I use) doesn’t say anything about pinyin, and the xpinyin package seems to do something different altogether.

Hum, the polyglossia hook seems to be broken. You probably want to file a bug report at tex-hyphen.

The babel version works for pdfTeX.

According to the documentation, you should be able to bypass polyglossia in XeLaTeX by directly using the low-level command, and it appears the following code, which you can build using xelatex, works (gives the same output as pdflatex with babel):

\documentclass{article}

\makeatletter
\newcommand\pinyin[1]{\begingroup \language=\l@pinyin #1\endgroup}
\makeatother

\begin{document}
\begin{minipage}{8em}
Woshi zhongguoren. Wo bushi beijingren.
\end{minipage}

\begin{minipage}{8em}
\pinyin{Woshi zhongguoren. Wo bushi beijingren. }
\end{minipage}

\end{document}