Skip to content

Instantly share code, notes, and snippets.

@wspr
Created October 15, 2010 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wspr/0f42f19422d446490e0e to your computer and use it in GitHub Desktop.
Save wspr/0f42f19422d446490e0e to your computer and use it in GitHub Desktop.
\documentclass[draft]{article}
\usepackage{color}
\frenchspacing
\fussy
\pagestyle{empty}
\makeatletter
\newbox\trialbox
\newbox\linebox
\newcount\maxbad
\newcount\linebad
\newcount\bestbad
\newcount\worstbad
\newcount\overfulls
\newcount\currenthbadness
\def\trypar#1\par{%
\showtrybox{\linewidth}{#1\par}%
}
\newcommand\showtrybox[2]{%
\currenthbadness=\hbadness
\maxbad=0\relax
\setbox\trialbox=\vbox{%
\hsize#1\relax#2%
\hbadness=10000000\relax
\eatlines
}%
\hbadness=10000000\relax
\setbox\trialbox=\vbox{%
\hsize#1\relax#2%
\printlines
}%
\noindent\usebox\trialbox\par
\hbadness=\currenthbadness
}
\newcommand\trybox[2]{%
\currenthbadness=\hbadness
\maxbad=0\relax
\setbox\trialbox=\vbox{%
\hsize#1\relax#2\par
\hbadness=10000000\relax
\eatlines
}%
\hbadness=\currenthbadness
}
\def\eatlines{%
\begingroup
\setbox\linebox=\lastbox
\setbox0=\hbox to \hsize{\unhcopy\linebox\hss}%
\linebad=\the\badness\relax
\ifnum\linebad>\maxbad\relax \global\maxbad=\linebad\relax \fi
\ifvoid\linebox\else
\unskip\unpenalty\eatlines
\fi
\endgroup
}
\def\printlines{%
\begingroup
\setbox\linebox=\lastbox
\setbox0=\hbox to \hsize{\unhcopy\linebox}%
\linebad=\the\badness\relax
\ifvoid\linebox\else
\unskip\unpenalty\printlines
\ifhmode\newline\fi\noindent\box\linebox\showbadness
\fi
\endgroup
}
\def\showbadness{%
\makebox[0pt][l]{%
\ifnum\currenthbadness<\linebad\relax
\ifnum\linebad=1000000\relax\expandafter\@gobble\fi
{\quad\color{red}\rule{\overfullrule}{\overfullrule}~{\footnotesize\sffamily(\the\linebad)}}%
\fi
}%
}
\makeatother
\begin{document}
\begin{minipage}{5cm}
\trypar
There is no just ground, therefore, for the charge brought against me by~
certain ignoramuses---that I have never written a moral tale, or, in more
precise words, a tale with a moral. They are not the critics predestined
to bring me out, and \emph{develop} my morals:---that is the secret. By and by
the ``North American Quarterly Humdrum'' will make them ashamed of their
stupidity. In the meantime, by way of staying execution---by way of
mitigating the accusations against me---I offer the sad history appended,---
a history about whose obvious moral there can be no question whatever,
since he who runs may read it in the large capitals which form the title
of the tale. I should have credit for this arrangement---a far wiser one
than that of La Fontaine and others, who reserve the impression to be
conveyed until the last moment, and thus sneak it in at the fag end of
their fables.\par
\end{minipage}
\hbadness=2000
\begin{minipage}{5cm}
\trypar
There is no just ground, therefore, for the charge brought against me by~
certain ignoramuses---that I have never written a moral tale, or, in more
precise words, a tale with a moral. They are not the critics predestined
to bring me out, and \emph{develop} my morals:---that is the secret. By and by
the ``North American Quarterly Humdrum'' will make them ashamed of their
stupidity. In the meantime, by way of staying execution---by way of
mitigating the accusations against me---I offer the sad history appended,---
a history about whose obvious moral there can be no question whatever,
since he who runs may read it in the large capitals which form the title
of the tale. I should have credit for this arrangement---a far wiser one
than that of La Fontaine and others, who reserve the impression to be
conveyed until the last moment, and thus sneak it in at the fag end of
their fables.\par
\end{minipage}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment