[Tex/LaTex] Table-like layout in plain TeX

plain-textables

Below image shows part of a document prepared with a word processor. Gray lines mark table borders and are only visible in edit mode (they will not be visible when document is printed but have been preserved as a hint at text layout). My question is how I can prepare a similar layout–text in two columns–with TeX (preferrably plain TeX).

enter image description here

Best Answer

If you want it centered,

$$
\vbox{\tabskip=0pt
\halign{\tabskip=4cm #\hfil&#\hfil\tabskip=0pt \cr
Date:\cr
Gr.& Declarant\cr}}
$$

Just to see what happens without the $$ for the centering:

$$
\vbox{\tabskip=0pt
\halign{\tabskip=4cm #\hfil&#\hfil\tabskip=0pt \cr
Date:\cr
Gr.& Declarant\cr}}
$$

\bigskip

\noindent X\vbox{\tabskip=0pt
\halign{\tabskip=4cm #\hfil&#\hfil\tabskip=0pt \cr
Date:\cr
Gr.& Declarant\cr}}X

\bye

enter image description here

If you want the columns to occupy half of the line width, here's how to do it:

$$
\vbox{\tabskip=0pt
\halign{\hbox to .5\hsize{#\hfil}&\hbox to .5\hsize{#\hfil}\cr
Date:\cr
Gr.& Declarant\cr}}
$$

If you omit the $$, add \noindent in front of \vbox; but this will not leave space above and below the table.

If you want line breaking, change \hbox to .5\hsize{#\hfil} into

\vbox{\hsize=.5\hsize\strut#\strut}

for bottom alignment or \vtop for to alignment. Of course this won't leave space between the two boxes. This can be obtained by reducing the \hsize inside the two boxes and adding some \tabskip glue between them.

For more information about tables in Plain TeX, see TeX by Topic (texdoc texbytopic on TeX Live) or this link