11

I would like to limit the scope of \fontspec to just one or a couple of words in my paragraph, for example:

Vivamus gravida lacus a sapien \fontspec{The Font Name}{interdum} eget 
interdum mi sodales. Aenean nisi nunc, feugiat a auctor sed, consectetur
ut elit. In id tellus ac lectus ullamcorper tempor

If I just want to change the font of the word interdum, what would be the correct way to do it?

(I'm using XeLaTeX under Mac OS X 10.7.2)

lockstep
  • 250,273
Mr.Gando
  • 725
  • 1
    Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it) – egreg Nov 18 '11 at 10:21

2 Answers2

15

Use braces to create a group:

\documentclass{article}
\usepackage{fontspec}
\begin{document}

Vivamus gravida lacus a sapien {\fontspec{Arial}interdum} eget
interdum mi sodales. Aenean nisi nunc, feugiat a auctor sed, consectetur
ut elit. In id tellus ac lectus ullamcorper tempor
\end{document}
Ulrike Fischer
  • 327,261
5

As an addition to Ulrike’s answer:

You could specify a new font family with \newfontfamily and then make a matching \text… command:

\newfontfamily\arial[⟨font features⟩]{Arial}
\newcommand*{\textal}[1]{{\arial #1}}

and use it like this

Vivamus gravida lacus a sapien \textal{interdum} eget
interdum mi sodales. Aenean nisi nunc, feugiat a auctor sed, consectetur
ut elit. In id tellus ac lectus ullamcorper tempor

fontspec manual section 6, p. 8.

Tobi
  • 56,353