Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
I replaced the {quoting} tag with {punctuation}. Read here why. –  lockstep Mar 5 '11 at 17:52
2  
You should not use babel with XeLaTeX. Did you mean to load polyglossia? –  Andrey Vihrov Mar 5 '11 at 18:10
3  
A couple of comments about your code. It's helpful to make a complete minimal example that compiles and shows your problem. In this case, the minimal document needs only the fontspec package and the xeCJK package to show the problem, nothing else. This shows that the problem is with the xeCJK package, which explicitly removes spacing after punctuation. It's supposed to do this only with CJK characters. Secondly, you shouldn't use babel with xelatex; you should use polyglossia instead. See this question. –  Alan Munn Mar 5 '11 at 18:11
    
@Alan Munn: Yes, thank you, it was the xeCJK package, and yeah, I'll remember to provide a full example next time -- the problem is gone (or rather... different, I get bigger spaces) when I add \setCJKmainfont{...} which I added after adding the character replacement and I mistakenly included here. Shame on me. :) –  Darth TeXer Mar 5 '11 at 18:20
2  
A note for xeCJK: East Asian ideographs (CJK texts), don't use space between words at all. Thus xeCJK ignore all spaces between CJK symbols, to prevent extra spaces introduced by line wrapping. xeCJK also make it possilbe to break line after CJK ideographs, and imporves the spacing for the CJK punctuations. There are some ambiguous width characters used both in CJK text and western text, such as double quotes. — This is the problem you meet. –  Leo Liu Mar 5 '11 at 18:48

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
1  
Actually I think the problem only arises if you don't set the CJKmainfont. If you do, the spacing actually works as advertised in the CJK manual (remove spacing only with CJK characters.) So I don't think you need to use the \makexeCJKinactive command to get things to work. –  Alan Munn Mar 5 '11 at 18:48
    
@Alan: If you don't set the CJK fonts, you actually don't need xeCJK at all. If you set the CJK main font, double quotes are typesetted in a different font, that's not required either. –  Leo Liu Mar 5 '11 at 18:58
    
I understand that; what I meant was that I could only replicate the problem by loading xeCJK and not setting the CJK main font. So removing all the \makexeCJK(in)active commands from your example still preserves the spaces in the English text. –  Alan Munn Mar 5 '11 at 19:08
1  
What's more, closing double quote is a CJK post-punctuation in xeCJK. xeCJK also removes the space after CJK post-punctuations. That's because that CJK puctuations are full width in many CJK fonts, there's already enough spacing. This feature of CJK font hides the problem. However, there're also some CJK fonts (like Darth uses) with half-width punctuations, then the problem appears clearly. –  Leo Liu Mar 5 '11 at 19:12
    
Ah, I see. So the problem is partially font-dependent. That makes more sense. –  Alan Munn Mar 5 '11 at 19:44

I know exactly what you mean. I will just jump right in and show you my macros solution:

> \glqq#SEL##INS#\grqq\,

The \, is just a "thin space" after the quotes to force a space after the quotation marks.

I use xelatex with babel all the time, works great darth vader. The following is in my heading:

%german package
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
share|improve this answer
3  
This is an editor dependent solution (TeXShop?). And although you are correct that you can sometimes use babel with XeLaTeX, it depends on the language; see Polyglossia, babel and xelatex but you should never use the inputenc package with XeLaTeX. –  Alan Munn May 22 '11 at 12:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.