Using fontspec (with xelatex
in this case), LetterSpace
in an option for fonts that allows for adjustment of the spacing between glyphs.
However, the hyperref
package seems to override this, as shown in the following MWE:
\documentclass[preview,convert]{standalone}
\usepackage{fontspec}
\setmainfont[Scale=MatchUppercase]{Libertinus Serif}
\setmonofont[Scale=MatchLowercase,LetterSpace=-10]{Liberation Mono}
\newfontfamily\regularmono[Scale=MatchLowercase]{Liberation Mono}
\usepackage{hyperref}
\begin{document}
http://www.example.com % main font
\texttt{http://www.example.com} % uses monofont
% respects LetterSpace
{\regularmono http://www.example.com} % without LetterSpace
\url{http://www.example.com} % uses monofont
% does not respect LetterSpace
\end{document}
In this example, the monospace text with \texttt{}
uses the LetterSpace
setting, whereas the monospace text with \url{}
, while clearly using the same font, does not appear to respect the LetterSpace
setting, despite it being set for all occurrences of the font (or so I thought I understood).
My question is what options there are for getting past this apparent limitation. In other words, how can one adjust the spacing between glyphs in hyperref
urls?
Edit: a related question was asked before (I looked several times for related questions but somehow missed this one).
\href{http://www.example.com}{\texttt{http://www.example.com}}
(does not handle special characters in the url).