Plain TeX: Line up some text boxes

You want to set the \hsize of your vertical boxes, and as you want to align the baseline of the first line in the vertical boxes you want \vtop. Probably you need to give TeX some 'room to manoeuvre' in terms of the narrow boxes, so I'd use \sloppy or similar (from LaTeX). You also probably want no \parindent but do seem to want a \parskip. That leads to something like

\long\def\parbox#1{%
  \leavevmode
  \vtop{%
    \hsize0.2\hsize % Pick your size here
    \parindent0pt %
    \parskip\baselineskip
    \sloppy
    #1\par
  }%
}
\def\sloppy{%
  \tolerance 9999 %
  \emergencystretch 3em %
  \hfuzz 0.5pt %
  \vfuzz \hfuzz
}
\noindent
\parbox{This is a sentence}\hfil
\parbox{This is another nice sentence.\par  Whoa, another paragraph!}\hfil
\parbox{ Hey look! A third sentence or two}
\bye

One could of course set things up to have a 'spread these evenly' mechanism for an arbitrary number of boxes if you wanted, but that looks like more work than it's worth (particularly for a plain TeX context where the mark-up usually hides very little). I've hard-coded the width here, but in a real case I guess you'd perhaps make that a second argument.


You may want to use \halign:

\long\def\vtopragged#1#2{\vtop{\hsize=#1 \raggedright #2}}

\begingroup
\parindent=0pt
\tabskip=0pt
\halign to\hsize{%
  \vtopragged{.2\hsize}{#}\tabskip=0pt plus 1fill &
  \vtopragged{.2\hsize}{\parskip=\baselineskip #}\tabskip=0pt plus 1fill &
  \vtopragged{.2\hsize}{#}\tabskip=0pt \cr
  This is a sentence.&
  This is another nice sentence.

  Whoa, another paragraph!&
  Hey, look! A third sentence or two.

  This one without a blank line between paragraphs.\cr
}
\endgroup
\bye

enter image description here

Tags:

Plain Tex