I haven't been able to find a suitable package that does what I want. The closest is parcolumns
and I've spent several hours trying to understand TeX programming and the parcolumns
style. While I got the most of it I've tried to tweak it and just can't get it to do what I want.
I'm curious if anyone either knows of a package or can write one up quickly that does the following:
You give it a
\\
terminated list just like enumerate and the number of columns;It internally groups the list by number of columns. (a,b,c,d,e) with
columns=2
will be grouped as ((a,b,c),(d,e));It then creates m rows (
\hbox
es, depending on the number of elements and column size). The nth row contains an\hbox
of the nth element in each group. This creates a matrixa d
b e
cEach element in the row tries to distribute itself evenly along the horizontal BUT if on element overlaps the next it will "push" it INSTEAD of overlapping it (and this will continue until there is no need to push);
No gaps between rows AND no end gap on last column (so one has to get the width of the largest element in the last column and set the column size to that).
The point here is we have a matrix of boxes BUT if the horizontal content of one box is larger than the space it is given it will simply shift the adjacent box over to make room for it BUT if not it will align in a distributed manner.
Hopefully that makes sense and there is already a package that does this. With parcolumns
I have two issues: When my elements are horizontally too large (even if just a little) they overlap the next column and I have to manually push that next element over (which may cause a chain reaction).
\documentclass{article}
\usepackage{tikz}
\scrollmode
\begin{document}
\newcommand{\drawrect}[1]{\fbox{\begin{tikzpicture} \fill (-#1,-1) rectangle (#1,1);\end{tikzpicture}}}
\noindent\fbox{\hbox to \linewidth{%
\drawrect{1.5}\hspace*{\fill}\drawrect{1.5}\hspace*{\fill}\drawrect{1.5}\\}}
\fbox{\hbox to \linewidth{\drawrect{2}\hspace{0.2cm}\drawrect{1.5}\hspace{1.2cm}\drawrect{1.5}\\}}
\fbox{\hbox to \linewidth{\drawrect{2.5}\hspace{0.2cm}\drawrect{1.5}\hspace{0.2cm}\drawrect{1.5}\\}}
\fbox{\hbox to \linewidth{\drawrect{2.4}\hspace{0.4cm}\drawrect{1.5}\hspace{0.2cm}\drawrect{1.5}\\}}
\end{document}
Here is an example situation
- Note that the first element of row 3 "pushes" or overlaps into the 2nd element of row.
- This causes the 2nd element to be offset by some amount (user specified). The 3rd element does not change positions though.
- In row 4, the first element is slightly smaller BUT note that the 2nd element is aligned with the one right above it BECAUSE it snaps to that position to for visual reasons.
- Also, if you were to add a fixed amount of whitespace to each element in the last column then you would end up causing problems (depends on how you set it up though). I want to remove this issue. To fix it we basically have to remove the whitespace so that at least one element in the last column has no whitespace. Hence we just "substract" the appropriate amount of whitespace from all columns and then at least one will have no whitespace. Note that this is only for calculating the column spacing. Essentially we just compute (
\linewidth
+ x)/#columns where x is the smallest amount of whitespace from the set of cells in the last column. This effectively increases the\linewidth
by the unused whitespace in the last column.
\\
separators it uses\item
) and the last point (you say the width of the last column is that of its widest entry, but what of other columns? widest entry in that column?) finally you say the entries are hboxes, but you compare with paracolumns which takes multiline material rather than hboxes as its items? – David Carlisle May 12 '12 at 0:36