5

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?

asr
  • 331

1 Answers1

3

enter image description here

\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}
David Carlisle
  • 757,742