# Defining a “narrowized” font for \setmonofont{}

Because of Corporate Design rules, I need to use the font SourceCodePro for monospaced text and Arial for plain text. Using KOMA Script, I declared

\setmainfont{Arial}
\renewcommand{\sfdefault}{\familydefault}
\setmonofont{Source Code Pro}


Unfortunately, the monospaced stands out too much (for my taste) when used for single words or lines of a paragraph. Other occurences might be tolerated but are not appealing. To reduce the pain, I use the macro

\newcommand{\mono}[1]{\texttt{\protect\scalebox{.9}[1.0]{#1}}}


which works well for plain text as expected but leads to problems

• when used in hyperref's \url macro (\mono{\url{...}} works if it's acceptable to lose the ability to break the text but \url{\mono{...} does not) and more annoyingly,

• does not work at all when used in listing's lstlisting environment.

Instead of trying to solve both issues somehow, I hope there is a way to pass the information to scale the font to \setmonofont{} and thus declare all occurrences of SourceCodePro to be narrow.

You can load the mono font with the option FakeStretch (manual of fontspec, example 17).

\documentclass{article}
\usepackage{fontspec}

\setmainfont{Arial}
\setsansfont{Arial}
\setmonofont{Source Code Pro}[FakeStretch=0.9]

\newfontfamily{\scp}{Source Code Pro}% for comparing

\begin{document}

Some words in Arial and \texttt{some in shrinked mono font}

Some words in Arial and {\scp some in unshrinked mono font}

\end{document}


• This is awesome! Do you wanna marry me? :-D – Twonky Jan 21 at 10:03
• On the other hand, this leaves problems with hyperref's \url macro. The url macro typesets the fakestretched letters, but uses the plain letter space which is too wide. My workaround would is \href{url}{\ttfamily url}. – Twonky Jan 21 at 11:45