# Using data from tabulary to typeset columns

While trying to write a better answer to this question, I've made several (probably quite bad) attempts to use the tabulary environment to typeset paragraphs to try to in some way be able to split a paragraph over several pages. As my last attempt incorporating trying to make a parallel environment look like a tabular environment and adjusting this solution gave me a lot of error messages, I've started to think on giving up on this idea..

It seems like the tabulary package typesets the table "twice". Is it possible to use a tabular environment for the first of these typesettings, and then outputting only the calculated column widths, without actually "drawing" the table?

• yes just open up tabulary and throw away the second half:-) I need to go but will be on line later may post if no one else has. – David Carlisle Jun 20 '13 at 17:12

Out of time to implement page breaking but this answers the request for a basic measurement scheme that does a tabulary style (well slightly similar:-) determination of the column widths without setting the table.

The macro measures each of the two arguments and then calculates column width so they have similar height when set. At that point (where the comment is in the code) you can do what you like, for tonight it just sets them in a \vtop (\parbox[t]) of the specified width, so page breaking would not be allowed within the paragraph.

The \ifdim tests prevent either column being set to less than 20% of the textwidth which is an arbitrary amount that could be changed but you need to avoid badly unbalanced input setting silly lengths like 1pt so some cut off is advisable (cf \tymin in tabulary)

Incidentally if you know that the content is all text so the baselines are naturally evenly spaced and matched in each column, it would be much easer to do page breaking rather than if the content can include boxes or as here display math that mean the potential break points in one column do not automatically line up with the break points in the other column.

\documentclass{article}
\usepackage{graphics}
\makeatletter

\long\def\twopara#1#2{%
\@tempdima\dimexpr\textwidth-\columnsep\relax
\setbox\z@\vbox{{#1\endgraf}}%
\setbox\tw@\vbox{{#2\endgraf}}%
\Gscale@div\tmp{\ht\z@}{\dimexpr\ht\z@+\ht\tw@\relax}%
\global\let\xtmp\tmp}%
\dimen@ \xtmp\@tempdima
\ifdim\dimen@<.2\@tempdima \dimen@.2\@tempdima\fi
\ifdim\dimen@>.8\@tempdima \dimen@.8\@tempdima\fi
\dimen@ii\dimexpr\@tempdima-\dimen@\relax
% do anything you want with
% #1 \dimen@ wide
% #2 \dimen@ii ide
% \columnsep in between
\hbox{%
\vtop{{\hsize\dimen@ \textwidth\hsize #1\endgraf}}%
\hspace\columnsep
\vtop{{\hsize\dimen@ii \textwidth\hsize #2\endgraf}}%
}}

\makeatletter

\begin{document}

\noindent X\dotfill X

\twopara{
a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a
}
{
b b b b b b b b b b b b b b b b b b b b b b b b b b
b b b b b b b b b b b b b b b b b b b b b b b b b b
}

\bigskip

\twopara{
a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a a a a a a a a a
}
{
b b b b b b b b b b b b b b b b b b b b b b b b b b
b b b b b b b b b b b b b b b b b b b b b b b b b b
$a=b$
b b b b b b b b b b b b b b b b b b b b b b b b b b
b b b b b b b b b b b b b b b b b b b b b b b b b b
b b b b b b b b b b b b b b b b b b b b b b b b b b

}

\end{document}

• Nice solution :) Thank you! However, why does it not use the whole page width? (depending on how much text is in the tw columns, the sum of the column widths is between 245pt and 260pt, whereas the text width of the standard LaTeX page is 345 pt) – malin Jun 21 '13 at 8:29
• @malin sorry silly late night edit before posting broke it:-) Fixed code and image. – David Carlisle Jun 21 '13 at 8:39
• It made me learn some new TeX magic by trying to understand the code, so it was probably a good thing.. :) – malin Jun 21 '13 at 11:43
• Will this give problems with counters? – malin Jun 21 '13 at 12:13
• yes any side effecting operations like incrementing a counter or writing to a file will happen twice. stick \def\@elt##1{\global\value{##1}\the\value{##1}\relax}% \edef\TY@ckpt{\cl@@ckpt}% at the start and  \TY@ckpt before the final run. That sorts out all latex counters. Sorting out write and things is a bit harder depending on how much you want to support. – David Carlisle Jun 21 '13 at 12:23