# Is it possible to change the font of the text from a listing?

I have a listing of my Java code currently the font is too big and the code runs off the page.

Here is what my listing looks like:

-
To reduce the length of the code you can use the `lstset` options `columns=fullflexible` and `basicstyle=\small` or even `basicstyle=\scriptsize`. – guillem Dec 14 '12 at 7:33

You can change `basicstyle` and `linewidth` to achieve what you want. I, for example, use the following within my lstlistings-settings:

``````basicstyle=\footnotesize\ttfamily,
linewidth=\textwidth
``````

Additionally, I import the courier package to get a nicer font for `ttfamily`using `\usepackage{courier}`

EDIT: I also use Java code within LaTeX documents quite regularly. This is how my total setup looks like:

``````\lstset{
basicstyle=\footnotesize\ttfamily,
linewidth=\textwidth,
numbers=left,
numberstyle=\tiny\emptyaccsupp,
columns=flexible,
numbersep=5pt,      % Abstand der Nummern zum Text
tabsize=3,
breaklines=true,
keywordstyle=\color{RoyalBlue}\textbf,
frame=bottomline,
stringstyle=\color{WildStrawberry}\ttfamily,
showspaces=false,
showtabs=false,
xleftmargin=17pt,
framexleftmargin=17pt,
framexrightmargin=5pt,
framexbottommargin=4pt,
showstringspaces=false,
literate=%
{Ö}{{\"O}}1
{Ä}{{\"A}}1
{Ü}{{\"U}}1
{ß}{{\ss}}2
{ü}{{\"u}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
}
@CodeKingPlusPlus You can use anything from `\tiny` to `\Huge` as a setting for `basicstyle`. Just the usual LaTeX way of setting the font size – PattaFeuFeu Dec 14 '12 at 9:10