# Lists shaped like tables [duplicate]

As the title implies, I would like to find a way to write (ordered) lists in the shape of a table. This is particularly suitable for homeworks, for instance.

The solution I came with to use the multicol package:

\documentclass{article}

\usepackage{multicol}

\begin{document}

\begin{multicols}{3}
[Solve the following equations:
]
\begin{enumerate}
\item Equation $1$
\item Equation $2$
\item Equation $3$
\item Equation $4$
\item Equation $5$
\item Equation $6$
\item Equation $7$
\item Equation $8$
\end{enumerate}
\end{multicols}

\end{document}


The problem is that when the columns does not have the same number of items, the last has a big blank space.

Therefore, is there a solution to have a list shaped like a table? Of course, I could manually write a tabular and number the items myself but it is not very convenient when deleting/adding an item. An excellent answer would give the option to choose whether the list is enumerated vertically or horizontally.

For the management of possible non-equal columns/rows (as in my example), the rule should be: when the list is enumerate vertically, the blanks spaces are at the bottom of the right column; and a the right of the last row when the enumeration is horizontal.

• The problem is that when the columns does not have the same number of items, the last has a big blank space. Then what is what you are looking for? How can that problem be solved if there are uneven number of items? – Manuel Nov 1 '14 at 15:56
• If you add \raggedcolumns after loading multicol the gap is at the bottom not between the items – David Carlisle Nov 1 '14 at 16:00
• You half imply you also want horizontal enumeration, for which see tex.stackexchange.com/questions/111173/… – David Carlisle Nov 1 '14 at 16:11
• Have you considered this approach or this other approach? – A.Ellett Nov 1 '14 at 21:02

You can use the tasks package, or use the shortlst package, that I have patched to have more flexibility.

I define a tabenumerate environment, which accepts two key=value arguments: nc is the number of columns (3 by default) and il is the baseline stretch (1.5 by default). The advantage with respect to other solutions is that if an item is wider than 1 column it automatically uses the next column. In addition, I define a \paritem command to insert a multiline item; it has an optional argument which is the number of columns used by this \paritem (1 by default), and a mandatory argument, the contents of the item.

Here is a demo of both solutions:

\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage{shortlst,setspace,xkeyval}%
\makeatletter
\newcounter{ncol}
\define@key{lex}{nc}[3]{\setcounter{ncol}{#1}}%% 3 columns by default
\define@key{lex}{il}[1.5]{\def\@intln{#1}}% interlining![1]
\newenvironment{tabenumerate}[1][]{%
\setkeys{lex}{nc,il,#1}
\settowidth{\labelwidth}{\mbox{(m)}}
\setlength{\leftmargini}{\dimexpr\labelwidth+\labelsep\relax}%[1][3]
\setlength{\shortitemwidth}{\dimexpr\linewidth/\value{ncol}-\labelwidth-2\labelsep\relax}%
\renewcommand{\labelenumi}{\ensuremath{\arabic{enumi}.}}
\setstretch{\@intln}
\begin{shortenumerate}}%
{\end{shortenumerate}
}%
\newcommand\paritem[2][1]{\item \parbox[t]{#1\shortitemwidth}{\setstretch{1}#2\medskip}}
\makeatother

\begin{document}

\noindent Solve the following equations:
\task Equation $1$
\task Equation $2$
\task Equation $3$
\task Equation $4$ is a rather long equation
\task Equation $5$
\task Equation $6$
\task Equation $7$
\task Equation $8$
\bigskip

\noindent Solve the following equations:
\begin{tabenumerate}
\item Equation $1$
\item Equation $2$
\item Equation $3$
\item Equation $4$ is a rather long equation
\item Equation $5$
\paritem[1] {Equation $6$ is another long equation}
\paritem[2] {Equation $7$ is a third long equation that stretches along two columns. }
\item Equation $8$

\end{tabenumerate}

\end{document} %


• Thank you. It is very helpful. A last question (not sure it is worth an independant question): I use the tasks as a substitute of itemize when having rows of items is better than a columns. But how can I automatically use the style of a given depth of enumerate as a style for tasks? (This follow-up question also gives me the opportunity to finally accept the answer :D) – Taladris Feb 12 '16 at 13:56
• I don't know, but if you know the style for enumerate at a given depth, you have tools to apply it. For instance, \settasks{counter-format=(tsk[a]),label-width=1.5em} sets the counter as (a), (b), (c), &c. with a width of 1.5em. It uses a system of key=value. See § 4, pp.8-11 of the documentation for details. – Bernard Feb 12 '16 at 15:43