# Code over two Pages and continue counting Lines

I'm using Minted to show my Javascript Code. It seems not possible to spread a code with Minted over two pages.

So i do it like shown in Algorithm over two pages, with itemized lists. But the Code reset the line counting. They use : \algstore{myalg} and \algrestore{myalg} for Algorithms. is there a same instructions to saving counting for Minted?

Code :

\documentclass{article}
% define the program :
\newfloat{program}{tbp}{lop}}%
\usepackage{caption}
\usepackage{minted}
\newminted{javascript}{bgcolor=lightgray,linenos=true,fontfamily=courier,fontsize=\footnotesize,frame=single}

\begin{document}
\begin{program}[H]
\begin{javascriptcode}
\\Code Part 1
\end{javascriptcode}
\caption{Same Caption}
\label{prog:samelabel}
\end{program}

\newpage

\begin{program}[H]
\ContinuedFloat
\begin{javascriptcode}
\\Code Part 2
\end{javascriptcode}
\caption{Same Caption}
\label{prog:samelabel}
\end{program}
\end{document}


Overview First Page

1 <html>
2  <body>
3   <script type="text/javascript">
4      document.write("Ich bin ein Javascript Code!");


Program 1.2 Same Caption

Overview Second Page

1   </script>
2  </body>
3 </html>


Program 1.2 Same Caption

That the caption are the same is ok, but the numbering is resetting on the next page.

Edit 1:

In the Minted and Fancyvrb Documentation i see an Option : [firstnumber=last] that means that the numbering is continued from the previous Float.

How can i use it here? i tried :

\begin{program}[H]
\ContinuedFloat
\begin{javascriptcode}[firstnumber=last]


but this dont do the Trick.

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. –  doncherry Apr 8 '12 at 9:13
Thank you! i added some! –  trouble Apr 8 '12 at 9:33
Thanks! To make it an actual MWE, please add a document class and all necessary packages (but only necessary ones!), as it'll say in the link I posted. You might need to add filler text (German Blindtext) to get the code to break over two pages. I recommend either the package lipsum or the package blindtext for that. –  doncherry Apr 8 '12 at 9:36

I found a way to resolve it :

\begin{program}[H]
\begin{minted}[bgcolor=lightgray,linenos=true,fontfamily=courier,fontsize=\footnotesize,frame=single]{javascript}
\\Code Part 1 : numbers going from 1..28
\end{minted}
\caption{Same Caption}
\label{prog:samelabel}
\end{program}

\newpage

\begin{program}[H]
\ContinuedFloat
\begin{minted}[bgcolor=lightgray,linenos=true,fontfamily=courier,fontsize=\footnotesize,frame=single,firstnumber=29]{javascript}
\\Code Part 2 change firstnumber value
\end{minted}
\caption{Same Caption}
\label{prog:samelabel}
\end{program}

-