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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Some fonts include stylistic variations of certain glyphs. But it seems like there is only a global switch for these alternates, as in this example from the fontspec manual:

\fontspec{Linux Libertine}
\textsc{a} \& h \\
\textsc{a} \& h

Is it possible to use stylistic alternates only for individual glyphs, e.g. only for the '&'-glyph?

share|improve this question
Hopefully in the long run these sorts of fonts move towards using CharacterVariants so that they can be toggled individually. The fontspec CharacterVariant feature corresponds to the cv(xx) OpenType tag, where (xx) is 00 to 99. – Will Robertson Sep 12 '11 at 11:23
up vote 9 down vote accepted

For the specific example you have in mind, the simplest solution is simply to redefine \& as the alternate version. This is especially true of \&, since it's already a macro. For the occasional other character, this route might also be best, i.e. simply define a macro to introduce the alternate.

There is a more complicated version using \XeTeXintercharclass that might be useful for choosing alternates for more characters. The basic technique is explained in the XeTeX documentation (texdoc xetex). Note that this solution will not work for LuaLaTeX, which does not support these interchar classes.

I've worked both methods in the following sample document:

% !TEX TS-program = XeLaTeX

\setmainfont[]{Linux Libertine O}

This is an \& not alternate 

% First the simple version

This is the alternate \& after redefinition.


This is back to the old \&

% Now the more complicated version:
\XeTeXinterchartokenstate=1 % enable character classes
\newXeTeXintercharclass\myalt % create a new class
\XeTeXcharclass `\& \myalt % add & to the class
% between any character of class 0 and \myalt add the alternate feature
\XeTeXinterchartoks 0 \myalt = {\begingroup\addfontfeature{Alternate=0}}
% between \myalt and any character end the group
\XeTeXinterchartoks  \myalt 0 = {\endgroup}
% between a word boundary and \myalt add the alternate feature
\XeTeXinterchartoks 255 \myalt = {\begingroup\addfontfeature{Alternate=0}}
% between \myalt and the word boundary end the group
\XeTeXinterchartoks  \myalt 255 = {\endgroup}
This is an \&  alternate. And one in the middle of a word: A\&B.

output of code

share|improve this answer
Thank you! I ended up using the second version and it works great. – Emerson Sep 12 '11 at 11:43

Your Answer


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.