4

I'd like to have a desription list in plain TeX where there is only a line break after the item tag if the tag width exceeds a certain value. Lets say the indentation of the tags is zero and the indentation of the item text is 3em. So if the tag text plus 1em is less or equal 3em the following text should follow directly (aligned at 3em), if it is larger than 3em there should be a line break after the tag. Ascii example of the list:

A   <text1>
AB  <text2>
ABC
    <text3>

All texts above should then be aligned at 3em.

The item macro usage should be of the form

\item{<tag>} <text>

So only the tag is the argument but not the following text.

I looked at TeXbook p. 106 where there is something similar but that didn't help.

1 Answer 1

3

Here I use 0.5em as the minimum separation, change it to suit you.

\def\fitem#1{%
  \par\noindent
  \hangindent 3em
  \setbox0=\hbox{#1}%
  \hbox to\hangindent{#1\hss}%
  \ifdim\wd0>2.5em \hfil\break \fi
  \ignorespaces
}

\def\a{some text }
\def\b{\a\a\a\a}
\def\test{Some text \b\b\b\b}

\test

\fitem{A} \test
\fitem{AB} \test
\fitem{ABC} \test
\fitem{ABCD} \test
\fitem{ABCDE} \test

\test

\bye

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .