Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm having trouble using the facyvrb package. I have the following code:

\section{My section}
\subsection{Subsection}

\begin{Verbatim}[frame=single] 
...lots of code...
\end{Verbatim}

However, pdflatex constructs a whole page just containing the subsection header, the rest of the page empty, and then, on the next page starts the verbatim section. How can I tell the Verbatim part to be exactly under the subsection, something like the [H] command with floats on figures?

share|improve this question
2  
@Timo --- Please edit your question and add a complete example code that reproduces the problem you describe. –  Ian Thompson Jun 22 '12 at 13:00
    
that is not possible with the package fancyvrb which you already load, it can have page breaks. Only the BVerbatim environment is put in a box (note the preceding B). As Ian wrote, give more informations ... –  Herbert Jun 22 '12 at 13:03
    
listings is based on fancyvrb ... –  Herbert Jun 22 '12 at 13:07
1  
Does this happen always or only when the subsection title falls near the end of a page? –  egreg Jun 22 '12 at 13:36

1 Answer 1

I can't see any problem.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{fancyvrb}
\usepackage{lipsum}
\usepackage{xcolor}

\begin{document}
\section{My section}
\subsection{Subsection}
\lipsum[1]
\begin{Verbatim}[frame=single,framerule=1mm,framesep=3mm,
   rulecolor=\color{red},fillcolor=\color{yellow}]
Verbatim line.
\end{Verbatim}

\begin{Verbatim}[frame=single,framerule=1pt,rulecolor=\color{blue}]
...lots of code...
\end{Verbatim}

\lipsum[1-2]
\end{document} 

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.