# \autorows style table with custom columns and dynamic row spanning

I'm trying to create a table environment similar to memoir's \autorow, (in that I can supply contents as a list, along with the number of columns) but with more complex requirements. I need to be able to use a custom column (similar to what I might do with \newcolumntype) so that I can add automatic custom numbering for each cell. I need to be able to specify an explicit width (let's call it x) for the table, and have items added to the table such that if adding at item to a row would cause that row's total length to exceed x, that item is instead added as a as a column-spanning cell in the next row. An item so long that it exceeds x even if placed in the first column should be allowed to overflow, or wrap within that cell/row. Rows should be left aligned. Here's a mock up illustrating the desired results:

I achieved the auto-numbering using the solution to this previous question.

I realize the solution to this is probably very complex; just knowing what approach to use would be a big help, since I expect an explicit solution probably well exceeds what would be reasonable to ask of someone else volunteering their time to write. Of course, if there's some simple solution I've overlooked, fantastic.

• Did you think of taking a look at the tasks package. Another possibility would perhaps be the shortlst package. See examples of its use with some patching I did on this thread. – Bernard Apr 3 '15 at 0:41
• I wouldn't recommend basing any solution on tabu. Avoid it like the plague. – cfr Apr 3 '15 at 1:06

## 1 Answer

As told in comments, avoid tabu for this and use tasks package. Here is an example.

\documentclass{article}
\usepackage[more]{tasks}

% new list-like environment
% \NewTasks[options]{name}[separator](default number of columns)
\NewTasks[style=enumerate,counter-format=tsk[1]),label-width=2ex]{myenumerate}[\item](3)

\usepackage{kantlipsum}% insert text fragments
\begin{document}

\kant[1]

\begin{myenumerate}
\item Added normally
\item two
\item three
\item four
\item*(2) This will occupy two columns as it is bigger
\item! This will occupy three columns as it is very much bigger and bigger This will occupy three columns as it is very much bigger and bigger
\item*(2) Again more columns text Again more columns text Again more columns text
\item eight
\item nine
\end{myenumerate}

\kant[2]

\begin{tasks}[style=enumerate,counter-format=tsk[1]),item-indent=0em,label-width=2ex](3)
\task Added normally
\task two
\task three
\task four
\task*(2) This will occupy two columns as it is bigger
\task! This will occupy three columns as it is very much bigger and bigger This will occupy three columns as it is very much bigger and bigger
\task*(2) Again more columns text Again more columns text Again more columns text
\task eight
\task nine
\end{tasks}

\end{document}


• This is awesome, but is there any way to make the column spanning totally automatic? I'd still have to "pre-check" which items will need to span and add the necessary arguments to each task manually. – Texman Apr 3 '15 at 5:30
• @Texman LaTeX can't know how many columns the text can span by itself. – user11232 Apr 3 '15 at 5:41
• @Kumar This is as good as it gets then. Thanks! – Texman Apr 3 '15 at 5:52