# Forcing a page break in \VerbatimInput (fancyvrb)

How do I force a page break within a file included with \VerbatimInput? It's C code, and I would prefer a solution that is transparent to the C compiler - something like a form feed (^L) in the source.

I copied the start of the texbook.tex file, where a couple of ^L are used. Then this code will break pages at those tokens:

\documentclass{article}
\usepackage{fancyvrb}

\def^^L{\par} % not outer
\def\aftereject{\aftergroup\afterejectI}
\def\afterejectI{\aftergroup\pagebreak}

\begin{document}

This will have page breaks

\VerbatimInput[defineactive=\def^^L{\aftergroup\aftereject}]{tbstart.tex}

\end{document}


Here is the part I put in the file

% This manual is copyright (C) 1984 by the American Mathematical Society.
% All rights are reserved!
% The file is distributed only for people to see its examples of TeX input,
% not for use in the preparation of books like The TeXbook.
% Permission for any other use of this file must be obtained in writing
% from the copyright holder and also from the publisher (Addison-Wesley).
\loop\iftrue
\errmessage{This manual is copyrighted and should not be TeXed}\repeat
\pausing1 \input manmac
\ifproofmode\message{Proof mode is on!}\pausing1\fi
^L% halftitle
\titlepage
\pageno=-1983
\line{\cmman The\hfill T\kern-10pt\lower13pt\hbox{E}\kern-5pt Xbook}
\vfill
\ifproofmode
\rightline{The fine print in the upper right-hand}
\rightline{corner of each page is a draft of intended}
\rightline{index entries; it won't appear in the real book.}
\rightline{Some index entries will be in |typewriter type|}
\rightline{and/or preceded by {\tt\char\\} or enclosed in \<$\ldots$>, etc;}
\rightline{such typographic distinctions aren't shown here.}
\rightline{An index entry often extends for several pages;}
\rightline{the actual scope will be determined later.}
\rightline{Please note things that should be indexed but aren't.}
\fi
\eject
^L% title
\pageno=-1 % the front matter is numbered with roman numerals
\font\auth=cmssdc10 scaled\magstep4 % used only on the title page
\font\elevenbf=cmbx10 scaled\magstephalf % ditto
\font\elevenit=cmti10 scaled\magstephalf % ditto
\font\elevenrm=cmr10 scaled\magstephalf % ditto
\titlepage
\line{\cmman The\hfill T\kern-10pt\lower13pt\hbox{E}\kern-5pt Xbook}
^^{Knuth, Donald Ervin}
^^{Bibby, Duane Robert}


Here ^L appears as two characters, so you should find a way for coercing your editor to insert the real ^L.

The first output page is as follows, note that the page break is taken just at the ^L.

Points to note

1. ^^L is made non outer
2. ^^L is already active
3. We have to pop two levels of boxing for getting where \pagebreak` has effect
• Thanks, that works perfectly! I couldn't have figured it out myself. – user92221 Nov 16 '15 at 14:31