I have a document similar to this:
\usepackage{listings}
\begin{document}
\lstset{language=Matlab,%
basicstyle=...
}
\subsection*{Matlab code}
\lstinputlisting{../myScript.m}
\end{document}
I have found several answers on how to use lstlisting with a monospaced font and a few on how to get a sans-serif font by setting basicstyle equal to \ttfamily or \sffamily respectively.
But what should I do if I like to display my source code in a monospaced AND sans-serif font?


\lstinputlisting{...}I think what is contained in my question is about the best "MWE" (or rather "ME") I can come up with as I shouldn't provide the rather text heavy input file.Besides it doesn't really matter what the input file is, so just write something in
sometext.txtand save it in the same folder as the TeX-file and replace../myScript.mwithsometext.txt.The reason I provide
– Malte Feb 03 '18 at 22:39basicstylewith no value is because I hoped that someone would fill it out solving my problem. However the answer doesn't seem that simple for pdfLaTeX...\usepackage{fontspec}followed by\setmonofont{...}to the preamble, but I hadn't luck in finding any font package names of the fonts in my system that are both monospaced AND sans-serif...but maybe I have got the approach all wrong? – Malte Feb 03 '18 at 22:43sometext.txt' and copy it into your question for people to copy-paste. You can usefilecontentsto make this more convenient, though people will deal with it if you don't. People are more likely to provide you with an example solution if all they have to do is add the font stuff to what you give them. They are less likely to if they have to complete your fragment first. You need a document class, too. – cfr Feb 03 '18 at 22:43basicstyle=\ttfamilyand you're done. – TeXnician Feb 04 '18 at 08:02