# Pinyin with pdfLaTeX: Problem with spacings

I want to write a document in english and some words in chinese using pdfLaTeX.

Here a MWE:

\documentclass{article}
\usepackage[UTF8]{ctex}
\begin{document}
nǔrén\v{a}amùtūou
\end{document}


This shows up as in the image below:

As you can see after the ǔ or the ū LaTeX puts automatically a free space even if it's not written in the code, but not after \v{a}.

1) Why happens this?

2) How can I avoid this problem? (As you can imagine its not easy to make the change every time)

Thank you for any suggestions.

ctex package loads CJKutf8 package with pdfLaTeX. CJKutf8 package loads inputenc with utf8 option. However, unicode characters like ǔ is not defined in utf8.def, so CJK package treats these characters as CJK wide symbols, using a CJK font. That's the problem.

To fix the problem, you can define these unicode characters yourself:

% pdfLaTeX
\documentclass{article}
\usepackage[UTF8]{ctex}
\usepackage{newunicodechar}
\newunicodechar{ǚ}{\v{\"u}} % or: \DeclareUnicodeCharacter{01DA}{\v{\"u}}
\newunicodechar{ū}{\={u}}
\newunicodechar{ǎ}{\v{a}}
\usepackage[T1]{fontenc} % necessary for \v{\"u}

\begin{document}

\end{document}


A better solution is to use XeLaTeX instead of pdfLaTeX. It's much easier to deal with unicode characters in XeTeX.

% XeLaTeX
\documentclass{article}
\usepackage[UTF8]{ctex}

\begin{document}

\end{document}


See also xpinyin package to input pinyin easier.

Related question: