[comp.text] LaTeX list environment

williamssi@.UCalgary.CA (03/30/89)

Hi, I would have though that someone has already need and implement a
LaTeX list environment that does the following:

labelone:    These items are similar to LaTeX's "description"
             environment, however they indent to the same spot.

longerlabel: Part of the same demonstration.


etc.

The command does not have to be fancy, just work.  It would be fine if
the user had to give the longest label as an argument.

Thanks.

Simon Williams      {utai, uunet!ubc-cs}!calgary!williamssi

hartzell@tigger (George Hartzell) (03/30/89)

In article <986@cs-spool.calgary.UUCP>, williamssi@.UCalgary writes:
>Hi, I would have though that someone has already need and implement a
>LaTeX list environment that does the following:
>
>labelone:    These items are similar to LaTeX's "description"
>             environment, however they indent to the same spot.
>
>longerlabel: Part of the same demonstration.
>
>
% George Hartzell Thu Jun 23 16:02:25 MDT 1988
%
%  this implements a list that looks like:
% 
%      label     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
%                xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
%      longlabel xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
%                xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
%      shrt      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
%                xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
% 
% 
% use as
% \begin{labeledlist}
%    \item...
% \end{labeledlist}
% pass in the longest label as the argument.
%
\def\mydescriptionlabel#1{\bf #1 \hfil}
\newenvironment{labeledlist}[1]{% the begin stuff
     \begin{list}{}{
     \settowidth{\labelwidth}{#1}
     \addtolength{\labelwidth}{1em}
     \setlength{\labelsep}{1em}
     % set up the left and right margins
     \setlength{\leftmargin}{.25in}
     \setlength{\rightmargin}{\leftmargin}
     \addtolength{\leftmargin}{\labelwidth}
     \addtolength{\leftmargin}{\labelsep}
     \let\makelabel\mydescriptionlabel}}% the end stuff
     {\end{list}}
-- 
George Hartzell			                 (303) 492-4535
MCD Biology, University of Colorado-Boulder, Boulder, CO 80309
hartzell@Boulder.Colorado.EDU  ..!{ncar,nbires}!boulder!hartzell

hartzell@tigger (George Hartzell) (03/30/89)

In article <7782@boulder.Colorado.EDU>, hartzell@tigger (George Hartzell) writes:
>% use as
>% \begin{labeledlist}
>%    \item...
>% \end{labeledlist}
>% pass in the longest label as the argument.

make that
\begin{labeledlist}{long label}
   \item[label1] ...
   \item[label2]...
\end{labeledlist}
g.
-- 
George Hartzell			                 (303) 492-4535
MCD Biology, University of Colorado-Boulder, Boulder, CO 80309
hartzell@Boulder.Colorado.EDU  ..!{ncar,nbires}!boulder!hartzell

williamssi@.UCalgary.CA (04/01/89)

In response to my query about a LaTeX list environment that indents
the body of an item by the length of the longest item label I received
the following from Terry L. Anderson.  Since he cannot easily post and
there might be others interested I'm posting it for him.


----------------------------enclosed message-------------------------
                         The following is a list style I use which I
think does what you want.  It is called as
  \begin{labeled}{1in}
  \item[label 1] ...
  \item[label 2] ...
  \end{labeled}

You specify the desired indent as the parameter.


%
% new list style called labeled -- similar to itemize but the label is
% set left justified in the label region and it takes the leftmargin
% as a parameter.  For example:
% 
% label        The item.  If it is continued onto a second line, the
%              continuation is indented as the first to leftmargin.
%
\def\labeledlabel#1{#1\hfil}
\def\labeled#1{\list{}{\leftmargin#1
\labelwidth\leftmargin\advance\labelwidth-\labelsep 
\let\makelabel\labeledlabel}}
\let\endlabeled=\endlist




			     --	Terry L Anderson
				AT&T Bell Laboratories -- Liberty Corners
				UUCP:	...!att!mozart!tla
				NET:	tla%mozart@RESEARCH.ATT.COM 	
				ATTMAIL: mozart!tla
				TeleMail: Terry.Anderson
				(201) 580-4428


-------------------------end of enclosure---------------------------

Thanks to those who responded.

Cheers, 
Simon Williams    {utai, uunet!ubc-cs}!calgary!williamssi