[Tex/LaTex] Minted, setstretch and font size


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.

\usepackage[nodisplayskipstretch]{setspace} \setstretch{1.5}
public class Foo
  public static void main(String[] args)
    for(int i=0; i<10; i++)

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 and fontsize=\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.