[comp.text.tex] variable length hanging indentation

eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (01/28/91)

acmfiu@serss0.fiu.edu (ACMFIU) writes:

>in plain tex, how would i be able to do the following:

>foo 1. this is line one that will overprint
>    on the second line if possible.
>    2. or text that fits on just one line.

>foofoo 1. this is line one that will overprint
>       on the second line if posssible.
>       2. or text that fits on just one line.

\setbox0\hbox{foo }
\hangindent\wd0 \noindent\box0
1. This is lineone that will overprint
on the second line if possible\hfil\break
2. or text that fits on just one line

Of course you write a macro around this mess...

Victor.

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (01/29/91)

As quoted from <1991Jan27.211543.29701@csrd.uiuc.edu> by eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout):
+---------------
| acmfiu@serss0.fiu.edu (ACMFIU) writes:
| >foo 1. this is line one that will overprint
| >    on the second line if possible.
| >    2. or text that fits on just one line.
| 
| >foofoo 1. this is line one that will overprint
| >       on the second line if posssible.
| >       2. or text that fits on just one line.
| 
| \setbox0\hbox{foo }
| \hangindent\wd0 \noindent\box0
| 1. This is lineone that will overprint
| on the second line if possible\hfil\break
| 2. or text that fits on just one line
| 
| Of course you write a macro around this mess...
+---------------

Or, for an automatic but possibly frangible version (note: the following code
is approximate and untested; ncoast lacks TeX, not to mention the disk space
for it):

\everypar{\hangparagraph}
\def\hangparagraph#1 {\setbox0\hbox{#1 } \hangindent\wd0 \noindent\box0\relax}
%		    ^ this space is required!

Which (for non-TeXnicians) means that every time a paragraph starts, the token
"\hangparagraph" is inserted.  \hangparagraph is then defined as a macro which
takes the first word of the paragraph (defined as anything up to the first
space) and sets up a hanging indent based on it, as described by Victor.

(Why "frangible"?  Because things like one-word paragraphs can fail.  And
there are probably other things that can also break it.)

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY