[comp.text] .ip environment redux

clayton@thumper.bellcore.com (R. Clayton) (04/09/88)

A while back I posted a latex environment providing .ip-like lists.  At
the time I noted the environment produced overfull \hbox errors when
nested.  Recently it was pointed out that the environment also exhausts
the \box and \dimen register spaces on long lists.  This new version
should fix both problems:

   \documentstyle{article}
   
   \catcode`@=11
   
   \newbox \itemlist@label
   \newdimen \itemlist@labelpad
   
   \def\itemlist@makelabel#1{%
      \setbox \itemlist@label =\hbox{#1}%
      \ifdim \wd\itemlist@label >\labelwidth
          \itemlist@labelpad = \textwidth
          \advance \itemlist@labelpad by -\rightmargin
          \advance \itemlist@labelpad by -\@totalleftmargin
          \advance \itemlist@labelpad by \labelwidth
          \hbox to \itemlist@labelpad {#1\hfill}%
      \else #1\hfill
      \fi
      }
   
   \newenvironment{itemlist}[1]
   {\begin{list}{}{\settowidth{\labelwidth}{#1}
   \setlength{\leftmargin}{\labelwidth}
   \addtolength{\leftmargin}{\itemindent}
   \addtolength{\leftmargin}{\labelsep}
   \let\makelabel=\itemlist@makelabel}}{\end{list}}
   
   \catcode`@=12
   
   \def\a{There is a certainty that an agreement will be signed on a
   political settlement.  I think that Pakistan and Afghanistan will come
   to an agreement.  And we with the Americans will agree to be guarantors,
   I think.}
   
   \begin{document}
   
   \begin{itemlist}{beta}
   \item[alpha] \a
   \item[beta] \a
   \item[gamma] \a
   \end{itemlist}
   
   \end{document}