%%% Custom overfull text

How to replace a black overfull rule at the end of too long lines
of a paragraph?

Well, there is no a direct way to do so, but one should never underestimate
\TeX's bells and whistles. First of all, we can test if the last (h)box was
overfull by checking the value of \type{\badness}; if it is larger then 10000 it
definitely means that the box was overfull (\type{\badness} never exceeds 10000 for
underfull boxes). Assuming that \type{\box0} is the box we want to test, we can say

\beginverbatim
\def\ooops{\hbox to\wd0{\setbox0=\hbox to\wd0{\unhbox0}%
  \unhbox0 \ifnum\badness>10000 \rlap{\sevenrm\quad Ooops!}\fi}}
\endverbatim

And how to get the box that is the line of a paragraph? By setting of the 
\type{\interlinepenalty} parameter to a strongly negative value we can force 
a page break between every two lines of a paragraph. In the \type{\output} 
routine, we can recognize those special penalties via the 
\type{\outputpenalty} parameter. The \type{\output} routine is not 
necessarily supposed to \type{\shipout} the page -- it may simply return all 
its content back to the `recent contributions'.

\beginverbatim
\interlinepenalty=-50000 % force the break between each two lines
\maxdeadcycles=50        % allow upto 50 \outputs with no \shipout
\newtoks\orioutput \orioutput=\output % wrap the original \output routine
\output
 {\ifnum\outputpenalty>-20000 \the\orioutput
  \else \ifnum\outputpenalty<-\maxdimen \the\orioutput
  \else
    \unvbox255        % flush the entire list back
    \setbox0=\lastbox % strip the very last box
    \nointerlineskip  % avoid doubled interline glue
    \ooops            % make the test and return the box back.
    \advance\outputpenalty by50000
    \penalty\outputpenalty % weak lie that nothing happened...
  \fi\fi}
\hfuzz=\maxdimen % no overfullrule, no messages
\hsize=1.5in     % provoke overfulls
...
\endverbatim

%%%

\begingroup
\def\ooops{\hbox to\wd0{\setbox0=\hbox to\wd0{\unhbox0}% reset the box to get \badness
  \unhbox0 \ifnum\badness>10000 \rlap{\sevenrm\quad Ooops!}\fi}}

\interlinepenalty=-50000 % force the break between each two lines
\maxdeadcycles=50        % allow upto 50 \outputs with no \shipout
\newtoks\orioutput \orioutput=\output  % wrap the original \output routine

\output
 {\ifnum\outputpenalty>-20000 \the\orioutput
  \else \ifnum\outputpenalty<-\maxdimen \the\orioutput
  \else
    \unvbox255        % flush the entire list back
    \setbox0=\lastbox % strip the very last box
    \nointerlineskip  % avoid doubled interline glue
    \ooops            % make the test and return the box back.
    \advance\outputpenalty by50000
    \penalty\outputpenalty % weak lie that nothing happened...
  \fi\fi}

\hfuzz=\maxdimen \hsize=2in
This completely useless example shows a not-so-useless trick, which might be 
used for quite advanced applications, such as line-numbering, some kind of 
paragraph decoration, page optimization and probably many others. Things 
become much more complicated if math displays, \type{\marks}, \type{\inserts} 
or \type{\vadjusts} come into play, but they don't spoil all of the game.\par
\interlinepenalty=0 \hfuzz=0pt
This completely useless example shows a not-so-useless trick, which might be 
used for quite advanced applications, such as line-numbering, some kind of 
paragraph decoration, page optimization and probably many others. Things 
become much more complicated if math displays, \type{\marks}, \type{\inserts} 
or \type{\vadjusts} come into play, but they don't spoil all of the game.\par
\endgroup
\endinput
