3

How can I increase the letterspacing (tracking) of monospace fonts in Xetex?

This doesn't seem to work:

\documentclass{minimal}
\setlength{\parindent}{0cm}
\usepackage{fontspec}

\begin{document}

\addfontfeature{LetterSpace=0}
HLHHLLH\\
\addfontfeature{LetterSpace=50.0}
HLHHLLH\\

\addfontfeature{LetterSpace=0}
\texttt{HLHHLLH}\\
\addfontfeature{LetterSpace=50.0}
\texttt{HLHHLLH}\\

\end{document}

Results in:

screenshot of rendering of non-tracking in fontspec monospace font

1 Answer 1

4

You should put the \addfontfeature inside the \texttt, and you must load the fonts with the fontspec commands:

\documentclass{article}
\setlength{\parindent}{0cm}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\setmonofont{Latin Modern Mono}
\begin{document}

\texttt{\addfontfeature{LetterSpace=50}HLHHLLH}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .