# Ignore badness 10000 in \ttfamily

Due to zero stretch in \ttfamily the lines get Underfull \hbox (badness 10000) often. I would like to ignore these, still being informed about other badnesses in the same paragraph. See the example:

\documentclass[twocolumn,draft]{article}

\usepackage[latin]{babel} % latin hyphenation

% this allows description label to spread multiple lines
\usepackage{enumitem}\setlist[description]{style=unboxed}

% change column width to show the issue
\textwidth16.5cm
\columnsep0.5cm

\hbadness1750 % we allow a bit larger \hbadness in the twocolumn mode

% my macro to print TeX code snippets
\gdef\printTeX#1{%
\begingroup\ttfamily
\def\\{\char92\relax}%
\def\{{\char123\relax}%
\def\}{\char125\relax}%
\def\'{\allowbreak}%
#1%
\endgroup
}

\begin{document}

\begin{description}

\item[\printTeX{\\newcommand\'\{<command>\}\'[<num args>]\'[<opt arg default>]\{<expansion>\}}] ---
In accumsan egestas est, vestibulum gravida nibh adipiscing in.
Maecenas fringilla porta dolor quis bibendum.
Nulla arcu libero, pharetra nec semper et, tempus a purus.
Nullam non mi sed nulla accumsan varius.
Nulla sit amet mi urna, eu cursus nunc.
Nunc et justo eros, sed vehicula felis.
Nulla aliquet turpis accumsan leo auctor facilisis aliquam lectus sagittis.

\end{description}

Plus text \ldots

\end{document}


It produces three "badness", I would like the first to be ignored (i.e. not even mentioned in the log) but the following two still shown.

Underfull \hbox (badness 10000) in paragraph at lines 27--35
\OT1/cmtt/m/n/10 \newcommand{<command>}[<num-args>][<opt-

Underfull \hbox (badness 10000) in paragraph at lines 27--35
\OT1/cmtt/m/n/10 arg-default>]{<expansion>} \OT1/cmr/m/n/10 --- In ac-cu-

Underfull \hbox (badness 1783) in paragraph at lines 27--35
\OT1/cmr/m/n/10 m-san ege-stas est, ve-sti-bu-lum gra-vi-da ni-bh

-

One way could be to allow some variability in the interword spacing:

\def\printTeX#1{%
\begingroup\ttfamily\spaceskip=.5em plus .1em minus .05em
\def\\{\char\\ }%
\def\{{\char\{ }%
\def\}{\char\} }%
\def\'{\allowbreak}%
#1%
\endgroup
}


However, lines like those are quite problematic when they don't fit a line: they should be split in some good place that doesn't spoil the understanding of the syntax you're trying to illustrate. So probably manual intervention is the best strategy for getting a decent result.

The problem of "hiding" the message has only one solution: avoiding the underfull line to begin with. The messages are produced when TeX has finished typesetting the paragraph, and it can't distinguish the underfull lines you don't care of.

-
oh ok, my fault, I should have specified it better: I would like the message to disappear, not the underfull box... –  yo' Jun 20 '12 at 15:32
@tohecz I don't think it's a good idea: you don't really need to have the typewriter type characters aligned over each other. However, the message is generated when the paragraph is being output, so if you have the two for the "normal part", you have also the first one. –  egreg Jun 20 '12 at 16:08
On the other hand, I prefer \raggedright over large interword spaces, and it happens to me that the line contains no spaces at all... –  yo' Jun 20 '12 at 20:54
I thought it might be possible to insert some skip at the end of a given line, which could be 0pt plus 1fil in this case -- that would leave the line as is and the badness would disappear. –  yo' Jun 20 '12 at 20:56
@tohecz You have to do it manually. I tried with combinations of \hfil\penalty X\hfilneg inserted between the "arguments", but did not succeed. I'll try again. –  egreg Jun 20 '12 at 21:00

After some discussion and hints from @egreg, I came to a good-working solution:

\def\'{\hfil\penalty9999\hfilneg}%
\def\ {\' }%


The only workaround is that one has to use \<space> instead of simple <space>, since <space>` will produce un-breakable space.

-