I am trying to insert some piece of code into my document, using the \lstinputlisting command. However the fonts displayed do not look too good. Is it possible to change the font size and style?
Asked
Active
Viewed 1.6k times
7
Martin Scharrer
- 262,582
user739807
- 601
2 Answers
11
You can use the optional argument to provide any listings options:
\lstinputlisting[basicstyle=\ttfamily\scriptsize,language=somelang]{filename}
For multiple listings you can set this settings globally (or locally to the current group) using \lstset{<options>}. See the listings manual for more details.
https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings
Y00
- 103
Martin Scharrer
- 262,582
5
\lstinputlisting obeys to the same options that are set with \lstset for the environment form. So something like
\lstset{basicstyle=\ttfamily,columns=fullflexible}
should do.
egreg
- 1,121,712
columns=fullflexibledo? Could we also set its text width for new line? – alper Oct 02 '22 at 14:32basewidth=0.5emsince I was not able to use\!inside the listing text – alper Oct 02 '22 at 14:46lstlisting? – egreg Oct 02 '22 at 14:48