kenny@uf.msc.umn.edu (Kenneth R. Goers) (02/14/91)
I've been trying to make up a listing environment that looks more like a man page option list than LaTeX's, but here's my problem. When you have an item label (ie, \item[Label]) and the \labelwidth is larger than the width of "Label" the label is right justified rather than left justified. For example: LaTeX list Environment: first First item in a list. foo Foo label. next Next Label. Want: first First label. foo Foo Label. next Next Label. There's not a peep about this in LaTeX manual. My question, how do you get LaTeX to left justify rather than right justify the label in it's field? kenny. PS, Trying to define a flushleft environment inside the braces ([]) of the item label does not work. -- -- Kenny Goers Minnesota Supercomputer Center kenny@msc.edu
wittig@gmdzi.gmd.de (Georg Wittig) (02/14/91)
kenny@uf.msc.umn.edu (Kenneth R. Goers) writes: >LaTeX list Environment: > first First item in a list. > foo Foo label. > next Next Label. >Want: > first First label. > foo Foo Label. > next Next Label. This one has been written by a colleague of mine: %---------------------------------------------------------------------% % 19.06.1987 M. Wershofen % % % % Environment DEFLIST % %---------------------------------------------------------------------% \newcommand{\deflabel}[1]{\bf #1\hfill}% \newenvironment{deflist}[1]% {\begin{list}{}{\settowidth{\labelwidth}{\bf #1}% \setlength{\leftmargin}{\labelwidth}% \addtolength{\leftmargin}{\labelsep}% \renewcommand{\makelabel}{\deflabel}}}% {\end{list}} Usage: \begin{deflist}{\hspace{1in}} % insert your favorite width here \item[first] First label ... \end{deflist} -- Georg Wittig GMD-Z1.IT P.O.Box 1240 | "Freedom's just another word D-W-5205 St. Augustin 1 (Germany) | for nothing left to lose" email: wittig@gmdzi.gmd.de | (from "Me and Bobby McGee", telephone: (+49) 2241 14-2294 | Janis Joplin, Kris Kristofferson)
darius@edm.isac.CA (Darius S. Naqvi) (02/15/91)
In article <3491@uc.msc.umn.edu> kenny@msc.edu (Kenny Goers) writes: >I've been trying to make up a listing environment that looks more like >a man page option list than LaTeX's, but here's my problem. > >When you have an item label (ie, \item[Label]) and the \labelwidth is >larger than the width of "Label" the label is right justified rather >than left justified. For example: > >LaTeX list Environment: > > first First item in a list. > foo Foo label. > next Next Label. > >Want: > > first First label. > foo Foo Label. > next Next Label. > >There's not a peep about this in LaTeX manual. My question, how do you get >LaTeX to left justify rather than right justify the label in it's field? > I've managed to get LaTeX to left justify the label. If you look in latex.tex, you will see that the `list' environment does the right justifying by doing {\hfil #1}. All you have to do is redefine \makelabel within your `list' environment to left justify: {#1 \hfil}. Here's the way I did it: % Command for typesetting text flush left in its \hbox \newcommand{\leftlab}[1]{{#1 \hfil}} % Environment for a list with each label flush left, in an 8em margin \newenvironment{llist}% {\begin{list}{}{\leftmargin=8em% \setlength{\labelwidth}{\leftmargin}% \addtolength{\labelwidth}{-\labelsep}% \renewcommand{\makelabel}{\leftlab}% } }% {\end{list}} This defines an environment `llist' (left-list) that does what you want, with a left margin of 8 em. You can't do something like \renewcommand{\makelabel}[1]{{#1 \hfil}} in the declaration section of the list environment, because LaTeX thinks that the argument belongs to the llist environment instead of the \makelabel command, and it gets all confused. Also, according to p. 174 of The LaTeX User's Guide, the ``begin definition'' and ``end definition'' sections of \newenvironment shouldn't contain any command- or environment-defining commands. My guess is that again, LaTeX gets confused by the arguments. At any rate, the trick I used above (defining \leftlab with an argument, then defining \makelabel equal to it) seems to work OK. >kenny. > >PS, Trying to define a flushleft environment inside the braces ([]) of the > item label does not work. >-- -- >Kenny Goers Minnesota Supercomputer Center kenny@msc.edu -- Darius S. Naqvi mail:darius@edm.isac.ca ISA Corp. uucp:{uunet,alberta}!ncc!isagate!darius Edmonton, Alberta, Canada phone:(403) 420-8081