# Resize the text and keep the color box the same size

Hi I have a gray box that contains my python code, I want to reduce the size of the code, but keep the grey box the same size. This is my latex code:

\lstset
{ %Formatting for code in appendix
language={Python},
basicstyle=\fontsize{9}{9}\ttfamily,
numbers=left,
stepnumber=1,
showstringspaces=false,
keywordstyle=\color{blue},
stringstyle=\color{ForestGreen},
tabsize=4,
breaklines=true,
breakatwhitespace=false,
}

\fcolorbox{gray}{gray!15}{
\lstinputlisting[language=Python]{./Code/get_zip_files.py}


Without specifying the font size, the output looks like this:

With the code I mentioned at the top (including the font size) it looks like this:

As you can see the box became smaller. Is there a way to keep the same size for the box but lower the font size at the same time?

It is probably best to set the frame up with the mechanisms that listings provides, e.g.

backgroundcolor=\color{gray!15},
rulecolor=\color{gray},
frame=tlrb


\documentclass{article}

\usepackage{listings,xcolor}

\lstset
{ %Formatting for code in appendix
language={Python},
basicstyle=\fontsize{9}{9}\ttfamily,
numbers=left,
stepnumber=1,
showstringspaces=false,
keywordstyle=\color{blue},
stringstyle=\color{green},
tabsize=4,
breaklines=true,
breakatwhitespace=false,
backgroundcolor=\color{gray!15},
rulecolor=\color{gray},
frame=tlrb
}

\begin{document}

\noindent
A full line of text before the sample code.
A full line of text before the sample code.
A full line of text before the sample code.
\begin{lstlisting}[language=Python]
import requests

path = 'A:/Thesis_project/SBP/'
\end{lstlisting}

\end{document}

• Thank you for the solution! – Adrian May 2 '19 at 17:59