# Enumeration in a table, with top-aligend column

The basic problem is that I need an enumeration in a table cell. The special requirement is to have the text in the cell (or whole column) left to this cell top-aligned.

My first approach is:

\begin{table}[h!]
\begin{tabular}{r|l}
\textbf{Input} &
some text\\
\textbf{Work} &
\parbox{\linewidth}{\begin{enumerate}
\item The first step
\item The second step which is very long, so this text is more than the table width and should be broken .
\end{enumerate}}\\
\textbf{Output}: & some other text.\\
\end{tabular}
\end{table}


Which yields to:

As you see, the text in the left column is not top aligned. I tried multiple ways, e.g. this one but could not fix it.

My second approach was to use nested tables:

\begin{table}[h!]
\begin{tabular}{r|l}
\textbf{Input} &
some text\\
\textbf{Work} &
\begin{tabular}[t]{ll}
1. & The first step \\
2. & The second step which is very long, so this text is more than the table width and should be broken.\\
\end{tabular}
\\
\textbf{Output}: & some other text.\\
\end{tabular}
\end{table}


Which fixes the alignment issue, but cuts the text:

I tried to fix the width of the inner table (see here) but this also did not work.

How can I have an enumeration in a table with the cells to the left top-aligned? Thank you!

• why not use package multirow Mar 24, 2021 at 6:55

I suggest you (a) use a tabularx environment, to avoid the tedium of having to calculate the width of the second column, and (b) use a minipage[t] environment to encase the enumerate environment.

\documentclass{article}
\usepackage{enumitem}
\usepackage{tabularx} % for 'tabularx' env. and 'X' column type
\begin{document}
\begin{table}[h!]
\begin{tabularx}{\textwidth}{ @{} r | X @{} }
\textbf{Input}  & Some text.\\
\textbf{Work}   &
\begin{minipage}[t]{\linewidth}
\raggedright % optional
\begin{enumerate}[noitemsep]
\item The first step
\item The second step is very long, so this text exceeds the
table width and should be line-broken automatically.\strut
\end{enumerate}
\end{minipage}\\
\textbf{Output} & Some other text.\\
\end{tabularx}
\end{table}
\end{document}

• how to get align=left for the enumerate items so that 1. starts under the S(ome) in first row Mar 24, 2021 at 7:07
• @jsbibra - Just add the option left=0pt to the optional argument of the enumerate environment.
– Mico
Mar 24, 2021 at 7:09

%Preamble
\usepackage{multirow}
%______________________%
\begin{tabular}{r|l}
\textbf{Input} &
some text\\
\multirow{-3}{*}{\textbf{Work}} &
\parbox{\linewidth}{\begin{enumerate}
\item The first step
\item The second step which is very long, so this text is more than the table width and should be broken .
\end{enumerate}}\\
\textbf{Output}: & some other text.\\
\end{tabular}

• You need to subtract ((width of the first column)+4\tabcolsep+\arrayrulewidth) from the width of the second column (which is currently set to \linewidth).
– Mico
Mar 24, 2021 at 7:01