Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

no page break in verbatim

454 views
Skip to first unread message

Prof. Filipe

unread,
Nov 29, 2006, 6:31:55 AM11/29/06
to
How can I prevent a pagebreak inside a verbatim enviroment ?
Thanks, Filipe

Olive

unread,
Nov 29, 2006, 12:59:30 PM11/29/06
to
Prof. Filipe wrote:
> How can I prevent a pagebreak inside a verbatim enviroment ?
> Thanks, Filipe
>

You can use

\vbox{\begin{verbatim}
[ verbatim material ]
\end{verbatim}}

The vbox is a TeX primitive command that work also in LateX. Maybe there
is a more LaTeX way to do this? But this works

Olive

Heiko Oberdiek

unread,
Nov 29, 2006, 1:03:39 PM11/29/06
to
Olive <oes...@noemail.org> wrote:

Of course, there is the environment "minipage".
Also \samepage could be tried:

\begingroup
\samepage
\begin{verbatim}
...
\end{verbatim}
\endgroup

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Josselin Noirel

unread,
Nov 29, 2006, 1:07:04 PM11/29/06
to
Olive wrote in message <456dc923$0$388$bf49...@news.tele2.nl>:

> \vbox{\begin{verbatim}
> [ verbatim material ]
> \end{verbatim}}

If I remember correctly, verbatim takes account of \interlinepenalty so
\samepage should work.

{\samepage
\begin{verbatim}
.
.
.
\end{verbatim}
}

Or maybe, more properly (not tested, though)

% Preamble

\usepackage{verbatim}
\newcounter{interlinepenalty}
\newenvironment*{nbverbatim}{%
\setcounter{interlinepenalty}{\interlinepenalty}%
\interlinepenalty = 10000
\verbatim
}{%
\endverbatim
\interlinepenalty = \value{interlinepenalty}%
}

% In the body

--
Joss

bert.r...@gmail.com

unread,
Dec 1, 2006, 9:07:23 AM12/1/06
to
Not related to the verbatim package, but to a problem I had when using
\samepage multiple times to ensure no pagebreaks occur inside sections
is that LaTeX somehow related the different \samepage commands even
when they were embraced by braces! I wanted LaTeX to insert pagebreaks
in between sections if necessary, the result was that all the sections
were forced on one page, overflowing it. The solution I found:

\newenvironment{unbreakable}{\samepage}{\pagebreak[0]}
\begin{unbreakable}
\section{A section in which no pagebreaks occur}
Everything written in this section will be forced on a page. LaTeX is
allowed to put pagebreaks before or after the section to make it fit
\end{unbreakable}

% Opportunity to break here

\begin{unbreakable}
\section{Another section}
Also this section is immune for pagebreaks
\end{unbreakable}

Best regards,
Birdy

On 29 nov, 19:07, noi...@clipper.ens.fr (Josselin Noirel) wrote:
> Olive wrote in message <456dc923$0$388$bf494...@news.tele2.nl>:

Donald Arseneau

unread,
Dec 1, 2006, 11:09:03 PM12/1/06
to
bert.r...@gmail.com writes:

> Not related to the verbatim package, but to a problem I had when using
> \samepage multiple times to ensure no pagebreaks occur inside sections
> is that LaTeX somehow related the different \samepage commands even
> when they were embraced by braces!

This certainly happens. You have to know how to use \sampepage right,
and it is a bit odd. The control of breaking within a paragraph depends
on whether \samepage is in effect _when_the_paragraph_ends_!

Also, \samepage does not prevent breaks between regular paragraphs.



> I wanted LaTeX to insert pagebreaks
> in between sections if necessary,

You will have better results putting \filbreak before the sectioning
commands (or in their definitions), and avoiding \samepage. It works
better.

> \newenvironment{unbreakable}{\samepage}{\pagebreak[0]}

Should be

\newenvironment{unbreakable}{\par\samepage}{\par\pagebreak[0]}

--
Donald Arseneau as...@triumf.ca

0 new messages