I'm using minted
package. My problem is \usepackage[nodisplayskipstretch]{setspace} \setstretch{1.5}
line. I do need this line stretch, but I don't want it to affect code sources generated by minted
.
How can this be done?
Also, I would like to be able to change font size used by code listings independently from rest of document. I think I want 10 or 11pts for code listings and 12pt for rest of the text.
\documentclass[12pt,a4paper]{mwrep}
\usepackage{minted}
\usepackage[nodisplayskipstretch]{setspace} \setstretch{1.5}
\begin{document}
\begin{minted}{java}
public class Foo
{
public static void main(String[] args)
{
for(int i=0; i<10; i++)
{
System.out.println(i);
}
}
}
\end{minted}
\end{document}
Best Answer
You could insert the following code in your document's preamble, after loading the
minted
package:Alternatively, you could start each
minted
environment with the following options:baselinestretch=1
andfontsize=\footnotesize
. The latter works because if you set the main font size to be 12pt, then\footnotesize
will switch to a font size that's 2pt smaller; if you want your code to be typeset in 11pt (and the main font size is still 12pt), you should use the command\small
instead of\footnotesize
.