I would like to convert a list of terms like : A, B, C, D, E, F
to a table like:
| A | B | C |
| D | E | F |
or
| A | C | E |
| B | D | F |
but without having to rewrite my table each time, as inserting items or moving/deleting some is really hard with big tables.
Does any package exists to help doing that ?
EDIT:
By using a mix of all of what you provided, here is a version which has alignement problems - without the center block, the vertical version is slightly moved on the right, but this is intended to be centered in my document - with the center block, the horizontal version is not centered.
However here it is :
\documentclass{book}
\RequirePackage{etoolbox}%
\newcounter{argcolumns}
\newcounter{argtargetcolumns}
\newcommand{\mylisttable}[3][h]{
\setcounter{argcolumns}{0}
\setcounter{argtargetcolumns}{#2}
\def\mytable{}
\def\mylist{}
\forcsvlist{\listadd\mylist}{#3}
\def\parser ##1{%
\ifnumequal{\value{argcolumns}}{\value{argtargetcolumns}-1}{%
\setcounter{argcolumns}{0}%
\expandafter\def\expandafter\mytable\expandafter{%
\mytable ##1 \cr%
}%
}{%
\stepcounter{argcolumns}%
\expandafter\def\expandafter\mytable\expandafter{%
\mytable ##1 & %
}%
}%
}%
\forlistloop{\parser}{\mylist}%
\begin{center}
\ifx #1v \expandafter\valign\else\expandafter\halign\fi{& \hbox spread 0.1em{\hfil\strut##\hfil}\crcr
\mytable%
\whileboolexpr{%
not (test {\ifnumequal{\value{argcolumns}}{0}}) and %
test {\ifnumless{\value{argcolumns}}{\value{argtargetcolumns}-1}}
}%
{%
& \stepcounter{argcolumns}%
}\setcounter{argcolumns}{0}\cr
}
\end{center}
}
\begin{document}
\mylisttable[h]{4}{aaaaaaaaa,b,caaaa,daaaaaaaaaaaa,e,faaaaaaaaaa,g,h}
\mylisttable[h]{2}{a,b,c,d,e,f,g,h}
\mylisttable[v]{2}{a,b,c,d,e,f,g,h}
\mylisttable[v]{2}{a,b,c,d,e,f,g,h}
\mylisttable[h]{2}{a,b,c,d,e,f,g,h}
\end{document}


Datatooland / orpgfplotstable. – Sep 05 '12 at 13:55\hbox,\vbox,\hfiland\vfil(and theirfillequivalent) to obtain a better result than your combination ofcenterandalign.I think maybe your problem comes from the fact that they use the same kind of glue at some point.
Also remember that these commands will always center your table in the column they belong to at best. Therefore, if your layout is asymetrical, you cannot expect it to be easily centerable on the page (but it will always be, related to the text).
– Samuel Albert Sep 06 '12 at 06:24\hboxand\vboxare boxes whose dimensions are horizontally or vertically fixed (although the horizontal dimension of a\vboxis also fixed via\hsize).\hfiland\vfilare horizontal and vertical glues.You will find detailed information on how to use these in there and an example on how to practically use these in the kind of situation you are in in there
– Samuel Albert Sep 07 '12 at 14:31