3

I have the following tex file :

\documentclass[12pt,a4paper,twoside]{report}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{
  language=Java,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  ={\small\ttfamily},
  numbers=none,
  numberstyle=\tiny\color{gray},
  =\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}
\begin{document}
\begin{lstlisting}[caption={Third median in terms of $\theta$ and $\phi$},label={lst:f4}]
p, t= var('p t') 
a=(-2*p*t^2-p^2*t)+(2*t*p-p^2)+t+1 
b=(p*t^2+2*p^2*t)+(2*t*p-t^2)-p+1 
c=(p*t^2-p^2*t)+(t^2+2*t*p+p^2)+t-p #3 sides (a,b,c) in terms of theta and phi
expand(2*a^2+2*b^2-c^2) #third median equation, m=1/2*sqrt(2*a^2+2*b^2-c^2)
        9*p^4*t^2 + 18*p^3*t^3 + 9*p^2*t^4 + 6*p^4*t + 18*p^3*t^2 - 18*p^2*t^3 -
         6*p*t^4 + p^4 - 22*p^3*t + 6*p^2*t^2 - 22*p*t^3 + t^4 + 2*p^3 - 6*p^2*t
         + 6*p*t^2 - 2*t^3 - 3*p^2 + 18*p*t - 3*t^2 - 4*p + 4*t + 4
\end{lstlisting}

\end{document}

I want to change the font of the listings to be smaller, probably \tiny. Can anyone guide me how to do it.

1 Answers1

5

The basicstyle key is probably what you're after, i.e.

\lstset{
basicstyle=\small\ttfamily,
...
}

\ttfamily is assuming you want to use the typewriter font. For smaller font than \small, replace \small with \footnotesize, \scriptsize or \tiny, depending on what you want.

There seems to be some keys missing from the key=value pairs in your lstset, you have ={\small\ttfamily} (which might be where you wanted basicstyle), and later =\color{blue}, though I don't what that was intended for, of course.

Torbjørn T.
  • 206,688