# How do I get the protrusion to work in XeTeX?

When I render my documents using pdfLaTeX and `microtype` they look fine, but when I switch to XeTeX the right edges of justified text look terrible: some lines overlfow, and hyphens look "indented". Is there a way to fix this?

-
My understanding is that the `microtype` package works with `pdflatex` and `lualatex`, but not (yet) with `xelatex`. Might you be able to switch from `xelatex` to `lualatex`? – Mico Feb 20 '12 at 0:06
@Mico: I'm new to this, so, yes — I guess. Are there issues or limitations I should look for? What should I put in my code to detect lulatex? – raxacoricofallapatorius Feb 20 '12 at 0:28
@Mico: FWIW, to start with, I get "letterspacing currently doesn't work with luatex. – raxacoricofallapatorius Feb 20 '12 at 0:33
Ah, I failed to mention that the official version of microtype, #2.4, only does protrusion and font expansion under lualatex. However, version 2.5, currently in advanced beta, does do a lot more, including letterspacing (for luatex >= 0.62). It's available at tlcontrib.metatex.org/cgi-bin/package.cgi/action=view/id=569. Be aware, though, that kerning and interword space adjusting is not (yet) available under lualatex, even if you use version 2.5. Finally, if you're interested primarily in letterspacing, you might want to use the `letterspace` package. – Mico Feb 20 '12 at 2:07
As a slightly unrelated question, I'm trying to compile my document with pdftex+microtype and I want to find a nice font (I was using Linux Libertine w/ xetex), where can I find a list of microtype compatible fonts? – s0rce Feb 20 '12 at 15:29

## 4 Answers

It is my understanding that margin kerning does work but that font expansion doesn't.

This is one of the reasons why I'm currently using pdflatex and not XeLaTeX: OpenType support in XeTeX is very good because of the `fontspec` package, but XeTeX is not fully compatible with `microtype`.

You don't explain why you need XeTeX, so I'll explain some possible alternatives that work well with `microtype`.

I really like `microtype` (it makes your documents look great), which is why I decided to drop XeLaTeX and use pdfLaTeX. The lack of OpenType support in pdfLaTeX then forced me to implement (some) OpenType font feature selection myself. For my purposes, the mechanism works. For example, it lets me select all relevant figure features, including fractional figures, alternate glyphs, and [more]. Still the mechanism doesn't provide as good a functionality as `fontspec`. (The most important implementation details are described in Chapter 16 of LaTeX and Friends.)

The recently published `fontaxes` package also provides some more general font feature selection (mainly figure feature selection). If all you need is the extra figure features, combining pdftex, `microtype`, then `fontaxes` may be worth your while.

I really hope that some day XeTeX will be fully compatible with `microtype` or that `fontspec` will be compatible with pdftex.

-
LuaTeX has also been suggested as an alternative, is there a reason to prefer XeTeX over LuaTeX, or over pdfLaTeX — or not to? – raxacoricofallapatorius Feb 20 '12 at 1:49
@raxacoricofallapatorius PdfTeX does not support opentype fonts. Also last time I checked LuaTeX had some problems with multilingual texts, in this case XeTeX is a better alternative. – pmav99 Jul 3 '12 at 7:21
I am not familiar with the procedure you propose. Since I don't have time to check it, I 'll take your word for it :). Anyway, working with XeLaTeX allows you to use unicode characters in your files and especially in math this is great (unicode-math). For those of us that don't use the Latin alphabet though, xelatex makes our life easier. – pmav99 Jul 3 '12 at 16:26
We are in total aggreement! :) – pmav99 Jul 4 '12 at 17:05

I use LuaTeX for the most part, but fall back on XeTeX if a document requires bidi.

Use TLContrib (see latex-alive.tumblr.com/post/1303450459 for concise instructions) to get the latest version of microtype. It supports protrusion in XeTeX, though not the other microtypographic features. Protrusion is already enough to fix the worst eyesores.

And if you don’t work with right-to-left languages, I think LuaTeX will meet all your needs, including the microtypographic.

-
Is there a way to detect if I'm using LuaTeX (vs. pdfTeX or LaTeX) in code — e.g., like `\@ifundefined{XeTeXversion}`? – raxacoricofallapatorius Feb 20 '12 at 2:06
@raxacoricofallapatorius There is at least the `ifluatex` package. – Torbjørn T. Feb 20 '12 at 7:14
@raxacoricoallapatorius: See tex.stackexchange.com/q/13172/5763 – Martin Schröder Feb 20 '12 at 9:19

If you end up using LuaTeX, you could also remove microtype entirely (ref):

``````\pdfprotrudechars=2
\pdfadjustspacing=2
\newfontfeature{Microtype}{protrusion=default;expansion=default;}
\defaultfontfeatures{Microtype,Ligatures=TeX}
``````

To get letterspacing, use soul (or soulutf8). Also, you can check for LuaTeX using ifluatex.

-

The current version (2.5a) of `microtype` supports protrusion. From the manual:

Note that character protrusion requires pdfTEX (version 0.14f or later), LuaTEX, or X TE EX (at least version 0.9997). Font expansion works with pdfTEX (version 1.20 for automatic expansion) or LuaTEX. The package will by default enable protrusion and expansion if they can safely be assumed to work. Disabling ligatures requires pdfTEX (≥ 1.30) or LuaTEX, while the adjustment of interword spacing and of kerning only works with pdfTEX

-