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 insometext.txt
and save it in the same folder as the TeX-file and replace../myScript.m
withsometext.txt
. The reason I providebasicstyle
with 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...sometext.txt
' and copy it into your question for people to copy-paste. You can usefilecontents
to 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.basicstyle=\ttfamily
and you're done.