# Use listing with automatic page break

I want to put some of my python-code in the appendix of my latex file. For that I use the following code:

\begin{minipage}[c]{0.95\textwidth}
\lstinputlisting[caption=Python script used for fitting multiple ochi-hubble-functions to the measured data, language=Python]{../Bolge/fit_best.py}
\label{pyFit}
\end{minipage}


The problem I have here is that my code is bigger than one page, but it does not make a page break when ending the page. (I am using minipage here for a proper line break in the code).
How can I improve the code so that my lstlisting will make a new page if necessary?

• Don't use minipage. listings has its own keys to change the width. Apr 8 '15 at 9:40
• BTW, package listings provides option label for a label, which can be referenced by \ref. Apr 8 '15 at 9:44
• @UlrikeFischer Do you want to write up an answer? Jan 1 '18 at 9:44
• @TeXnician well imho the question has been abandoned, but I added an answer ... Jan 1 '18 at 23:02

Don't use minipage. listings has its own keys to change the width e.g. linewidth, xleftmargin and more. See "5.8 Margins and line shape" in the documentation of listings.
\documentclass{article}