I'd like to use the luximono face for monospaced typesetting under XeLaTeX. Since it is already installed in the MikTeX distribution under T1 encoding, I switch to the latter when I need monospaced type. In order to do this, I have defined corresponding commands, as shown in the MWE below. Now, if I do not redefine the control sequence \nobreakspace in a form such as, e.g., I have done for my MWE, I get the error message Command \nobreakspace unavailable in encoding T1. My redefiniton is a workaround to this problem, and it has to it more of a patch than of a satisfactory solution. Could anyone possibly explain what is going on and how to solve it in a more appropriate way?
\documentclass[11pt]{memoir}
\usepackage[T1]{fontenc}
\usepackage{mathpazo}
\usepackage{fontspec}
\usepackage{xunicode}
\defaultfontfeatures{Numbers=OldStyle,Ligatures=TeX}
\setmainfont[BoldFont=texgyrepagella-bold.otf,
ItalicFont=texgyrepagella-italic.otf,
BoldItalicFont=texgyrepagella-bolditalic.otf]{texgyrepagella-regular.otf}
\usepackage{microtype}
\newcommand{\xlxmono}{
\def\nobreakspace{\nobreak\space\nobreak}
\fontfamily{ul9}\fontencoding{T1}
\selectfont
}
\renewcommand*{\ttfamily}{\xlxmono}
\renewcommand*{\texttt}[1]{
{\xlxmono #1}
}
\begin{document}
{\ttfamily This is one line set in a monotype face with a nobreakspace command~here.}
\texttt{This makes for yet another line with~it.}
\end{document}
fontencwithfontspec: the latter uses special 'Unicode encodings' as the way things work with XeTeX and LuaTeX is very different from 'traditional' LaTeX encodings. – Joseph Wright Aug 13 '12 at 13:39kpfontswithfontspec? – Denis Bitouzé Apr 20 '16 at 08:56microtypewhich behaves differently with PDFLaTeX and with LuaLaTeX). – Denis Bitouzé Apr 20 '16 at 12:39