2

I'm creating a new environment to include a python code in my latex file. It works but the code is longer than one page and doesn't continue in the next page, it is cutted and interrupted at the and of the page. And also it's cutted on the right. How can i fix that?

My environment:

\lstnewenvironment{codice_testo}[1][]
{\lstset{basicstyle=\small\ttfamily, columns=fullflexible,
keywordstyle=\color{red}\bfseries, commentstyle=\color{blue},
language=Python, basicstyle=\small\ttfamily,
numbers=left, numberstyle=\tiny,
stepnumber=1, numbersep=5pt, frame=shadowbox, float=*, #1}}{}
3
  • 1
    I guess that float=* causes the problem. A floating object cannot be larger than one page. However, I have never tried to typeset a listing that is larger than one page.
    – Matthias
    Oct 31, 2017 at 19:15
  • As for the truncation on the right side, give the options breaklines=true and, at your choice, also breakautoindent=true a try.
    – Matthias
    Oct 31, 2017 at 19:19
  • I remove float=* and now the code goes to the next page, thanks @Matthias Oct 31, 2017 at 19:21

1 Answer 1

3

Remove the option float=* because a floating object cannot be larger than one page.

Add the option breaklines=true to avoid truncation at the right side. The additional option breakautoindent is true by default which is a good choice. The amount of indentation can be controlled by breakindent=<dimension> and defaults to 20 pt. (See manual for version 1.6, page 35.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .