# fancyvrb and \overfullrule

I know I can use \overfullrule=5pt to get overfull lines marked with a black marker, but using the Verbatim environment from the fancyvrb package the overfull lines are not marked. For example,

\documentclass{article}
\usepackage{fancyvrb}

\overfullrule=5pt

\begin{document}
\mbox{Overfull line marked without using the Verbatim environment from the fancyvrn package.}

\begin{Verbatim}
Overfull line not marked using the Verbatim environment from the fancyvrb package.
\end{Verbatim}
\end{document}


Note: I know I can use the BVervatim environment to mark the overfull lines, but it changes all the code layout in my document.

Is it possible to use the Verbatim environment and to get the overfull lines marked?

-
Welcome to TeX.sx! –  Kurt Dec 3 '12 at 16:39

\documentclass{article}
\usepackage{fancyvrb}

\overfullrule=5pt
\makeatletter

\let\oldFancyVerbFormatLine\FancyVerbFormatLine
\def\FancyVerbFormatLine#1{%
\setbox0\hbox{\oldFancyVerbFormatLine{#1}}%
\ifdim\wd0>\textwidth
\hbox{\box\z@\vrule\@width\overfullrule}%
\else
\box\z@
\fi}
\makeatother

\begin{document}
\mbox{Overfull line marked without using the Verbatim environment from the fancyvrn package.}

\begin{Verbatim}
Overfull line not marked using the Verbatim environment from the fancyvrb package.
short line
Overfull line not marked using the Verbatim environment from the fancyvrb package.
\end{Verbatim}

\end{document}

-
Thanks. This is exactly what I needed. –  asr Dec 4 '12 at 6:08