[Tex/LaTex] Space after closing double quotes in XeLaTeX

punctuationspacingxetex

I'm writing some non-technical text that I'm trying to typeset using XeLaTeX. For simplicity, I'm keeping the actual text in plain text files which after certain modifications (e.g. escaping %, \ and $, although I don't use these characters right now) become a subset of LaTeX. Something like this:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. 

Ut enim ad minim veniam, quis nostrud exercitation ullamco 
laboris nisi ut aliquip ex ea commodo consequat. Duis aute 
irure dolor in reprehenderit in voluptate velit.

I'm using Unicode characters for things like quotes and dashes (, , , , etc.) When I used LaTeX, this worked fine. But when I switched to XeLaTeX, it no longer puts spaces after the quotes. I wrote a script that manually converts all the characters to their equivalents (two backticks, '', --, ---, etc.) which worked as a workaround.

For example, when I have the following code:

“It's a big problem,” he said.

``What's the problem,'' I asked.

It's rendered as:

“It’s a big problem,”he said.

“What’s the problem,” I asked.

My question is, is there a way to make XeLaTeX work properly without replacing all those characters?

The preamble of my .tex files follows (although it's merely temporary, as I'm still working on the content).

\documentclass[a5paper,10pt]{book}
\usepackage{fullpage}
\usepackage[serbian,english,french]{babel}
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{xeCJK}
\setCJKmainfont{Sazanami Mincho}
\usepackage[a5paper]{geometry}

Best Answer

That's the effect of xeCJK, it uses CJK fonts for these punctuations. If you don't need Japanese text (Sazanami Mincho is a Japanese font), you can delete it and \setCJKmainfont command. And if you use only a little, you can use \makexeCJKinactive to disable xeCJK for most western text of your document. I'm sorry that this command is not well documented in the English part of the manual. (I'm one of the developers of xeCJK.)

An example:

\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{Adobe Song Std}% a Chinese font
\begin{document}
\makexeCJKinactive

“Western text,” Okey.

\makexeCJKactive
“中文”(Chinese text)
\makexeCJKinactive

\end{document}

enter image description here

BTW, babel may not work well with XeLaTeX and fontspec. However, polyglossia package may conflict with xeCJK, even if you use \makexeCJKinactive, they both use the \XeTeXinterchartoks to change the fonts for different glyphs. I didn't tested, thus I'm not quite sure about the compatibility.

If you use Japanese for only a few words, e.g. names of persons, you don't need xeCJK. You can just change the font manually for these words.