6

I have an enumeration of 15 items. How can I make those items appear in a 3x5 table?

So I want to have exactly one enumerate item per table cell:

----------------------------------
| 1. This is | 2     | 3 Another |
| item 1     | text  | item      |
----------------------------------
| 4  etc.    | 5     |  6        |
----------------------------------
...
  • Does using tabular instead of enumerate suffice, or is there a reason it has to be input as an enumeration? – Steven B. Segletes Jan 14 '14 at 14:08
  • I want to be able to reference the individual items. Is that possible with a pure tabular? – Jack Miller Jan 14 '14 at 14:09
  • This is certainly possible, but I am cautious if it's really A Good Idea. Why do you want it set up in a table? – Sean Allred Jan 14 '14 at 14:17
  • To save space. Writing all items below one another needs a lot of space. – Jack Miller Jan 14 '14 at 14:20
7

Here are two ways to do this. The simplest is to use the multicol package, and a regular enumeration, but this will end up with the numbering of the items by column rather than by row. If this is acceptable, then it's by far the easiest solution. To deal with referencing, you can add labels to any item as normal.

A more klunky solution is to create an enumerated table environment. This is what I've done in the second example. I've used the array package to create a new column type T which is actually two columns, one to contain the enumeration and the other to contain the content. To make the syntax similar to an enumeration, I've redefined \item within that environment, but you still need to add & and \\ at the end of each item as in a regular table.

The tabularlist environment takes one argument for the cell label prefix, and then a regular tabular specification in terms of the T column.

The length passed to the T column type corresponds to the proportion of the \linewidth the column should take up. For a three column table, this should be set to .27; for a two column table it should be set to about .45.

The cell label prefix sets up an automatic label for every cell, to handle the referencing issue. In the example document I have used the following form:

 \begin{tabularlist}{TAB1}{T{.27}T{.27}T{.27}}

This sets up a label for each cell in the table that is of the form \label{TAB1:<cell number>}, so if you want to refer to Cell 5, you would simply use \ref{TAB1:5} in the reference text.

I've also added a user-settable length \tblenumlabelspace for the spacing between the enumeration label and the content.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{multicol}
\usepackage{array}
\usepackage{etoolbox}
\newenvironment{tabularlist}[1]{%
\preto{\tabular}{\renewcommand{\item}{\label{#1:\thetblenum} &} \setcounter{tblenum}{0}}
\setlength{\extrarowheight}{.5\baselineskip}
\begin{tabular}}
{\end{tabular}}
\newcounter{tblenum}
\newlength{\tblenumlabelspace}
\setlength{\tblenumlabelspace}{.75em}
\newcolumntype{T}[1]{@{}>{\refstepcounter{tblenum}\thetblenum.}
   r@{\hspace{\tblenumlabelspace}}p{#1\linewidth}}


\begin{document}
\begin{multicols}{3}
\begin{enumerate}
\item First item is long and will wrap.
\item Second item
\item Third item
\item Fourth item
\item Fifth item
\item Sixth item 
\item Seventh item
\item Eighth item 
\item Ninth item
\item Tenth item
\item Eleventh item
\item Twelfth item
\item Thirteenth item
\item Fourteenth item
\item Fifteenth item
\end{enumerate}
\end{multicols}

\noindent
\begin{tabularlist}{TAB1}{T{.27}T{.27}T{.27}}
\item First item that is quite long and will wrap. &
\item Second item &
\item Third item\\
\item Fourth item &
\item Fifth item &
\item Sixth item\\
\item Seventh item &
\item Eighth item &
\item Ninth item\\
\item Tenth item &
\item Eleventh item &
\item Twelfth item \\
\item Thirteenth item &
\item Fourteenth item &
\item Fifteenth item
\end{tabularlist}

\bigskip
In Item \ref{TAB1:5} we can see \ldots.
\end{document}

output of code

  • package multicols does not work with package savetrees, so I ended up using the other option. – Jack Miller Jan 20 '14 at 6:51
  • @JackMiller As far as I can see, the savetrees package certainly works with multicol (note that the package name doesn't use an s, but the environment does.) Adding savetrees to my sample document causes no errors. – Alan Munn Jan 20 '14 at 11:05
0

Even though Alans solutions is nicer (for my usage), I'd like to share my preliminary work around:

I used package gb4e to create customized, enumerated environments. One for each cell. For better reading of the table I put the text of each cell item in its own command.

\documentclass{article}

\usepackage{gb4e}

\begin{document}

\newcommand{\myHeaderLabel}[2]{\vspace{-1.4em} \begin{exe} \ex \label{#2}  \texttt{#1:} \end{exe} \vspace{-1em}}

\newcommand{\entryA}{
    \myHeaderLabel{Item}{i:labelA}
    First item is long and will wrap.
}
\newcommand{\entryB}{
    \myHeaderLabel{Item}{i:labelB}
    Second item
}
\newcommand{\entryC}{
    \myHeaderLabel{Item}{i:labelC}
    Text, text, text
}
\newcommand{\entry}{
    \myHeaderLabel{Another item}{i:label}
    Text, text, text
}

\begin{table}[h]
    \caption{One item per table cell}
    \begin{tabular*}{\hsize}{@{\extracolsep{\fill}}
                    p{\dimexpr \textwidth/3-1\tabcolsep}
                    p{\dimexpr \textwidth/3-2\tabcolsep}
                    p{\dimexpr \textwidth/3-1\tabcolsep}@{}}
        \hline
            \entryA  &  \entryB  &  \entryC  \\
        \hline
             \entry  & \entry  &  \entry  \\
        \hline
             \entry  & \entry  &  \entry  \\
        \hline
             \entry  & \entry  &  \entry  \\
        \colrule
             \entry  & \entry  &  \entry  \\
        \hline
    \end{tabular*}
    \label{tab:useCases}
\end{table}

In Items \ref{i:labelA} and \ref{i:labelB} we can see \ldots.

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.