0

Listings like

\begin{listing}
\begin{minted}[linenos,breakanywhere,breaklines]{python}
    # long code
\end{minted}
\label{lst:label}
\end{listing}

will go over the page number and generate a Float too large for page by X.Xpt. warning.

How to get that listing to span into two or more pages?

The solution using \captionof or defining a new environment as suggested here isn't working well for me because I need the listing to have the same margins like the original \listing.

EDIT:

I need this source code

%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Define Article %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Using Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{geometry} \usepackage{graphicx} \usepackage{amssymb} \usepackage{amsmath} \usepackage{amsthm} \usepackage{empheq} \usepackage{mdframed} \usepackage{booktabs} \usepackage{lipsum} \usepackage{graphicx} \usepackage{color} \usepackage{psfrag} \usepackage{pgfplots} \usepackage{bm} \usepackage{svg} \usepackage{minted} \setmintedinline{breaklines,breakanywhere} \usepackage{csquotes} \usepackage{biblatex} \usepackage[hidelinks]{hyperref} \usepackage{tikz} \usepackage{tikz-uml} \usepackage{adjustbox} \usetikzlibrary{positioning} \usetikzlibrary{arrows.meta} \usepackage[final]{microtype} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Other Settings

%%%%%%%%%%%%%%%%%%%%%%%%%% Page Setting %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \geometry{a4paper}

%%%%%%%%%%%%%%%%%%%%%%%%%% Define some useful colors %%%%%%%%%%%%%%%%%%%%%%%%%% \definecolor{ocre}{RGB}{243,102,25} \definecolor{mygray}{RGB}{243,243,244} \definecolor{deepGreen}{RGB}{26,111,0} \definecolor{shallowGreen}{RGB}{235,255,255} \definecolor{deepBlue}{RGB}{61,124,222} \definecolor{shallowBlue}{RGB}{235,249,255} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%% Define an orangebox command %%%%%%%%%%%%%%%%%%%%%%%% \newcommand\orangebox[1]{\fcolorbox{ocre}{mygray}{\hspace{1em}#1\hspace{1em}}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%% English Environments %%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newtheoremstyle{mytheoremstyle}{3pt}{3pt}{\normalfont}{0cm}{\rmfamily\bfseries}{}{1em}{{\color{black}\thmname{#1}~\thmnumber{#2}}\thmnote{,--,#3}} \newtheoremstyle{myproblemstyle}{3pt}{3pt}{\normalfont}{0cm}{\rmfamily\bfseries}{}{1em}{{\color{black}\thmname{#1}~\thmnumber{#2}}\thmnote{,--,#3}} \theoremstyle{mytheoremstyle} \newmdtheoremenv[linewidth=1pt,backgroundcolor=shallowGreen,linecolor=deepGreen,leftmargin=0pt,innerleftmargin=20pt,innerrightmargin=20pt,]{theorem}{Theorem}[section] \theoremstyle{mytheoremstyle} \newmdtheoremenv[linewidth=1pt,backgroundcolor=shallowBlue,linecolor=deepBlue,leftmargin=0pt,innerleftmargin=20pt,innerrightmargin=20pt,]{definition}{Definition}[section] \theoremstyle{myproblemstyle} \newmdtheoremenv[linecolor=black,leftmargin=0pt,innerleftmargin=10pt,innerrightmargin=10pt,]{problem}{Problem}[section] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plotting Settings %%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepgfplotslibrary{colorbrewer} \pgfplotsset{width=8cm,compat=1.9} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Title & Author %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \title{Title} \author{Antonio Santoro} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document} \maketitle

\begin{listing}
    \begin{minted}[linenos,breakanywhere,breaklines]{python}
    async def start(self):
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #

    async def _handle_req(self, reader: StreamReader, writer: StreamWriter):
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
        #
    \end{minted}
    \caption{Caption}
    \label{lst:server-async}
\end{listing}

\end{document}

to be spanned into multiple pages. Right now the generated document looks like this

enter image description here

Float too large for page by 349.24756pt.

0 Answers0