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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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}
share|improve this answer
    
Thanks. This is exactly what I needed. – asr Dec 4 '12 at 6:08

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.