# Lists mixed with tabular in latex

I have a large table where the first column is a list of items (using both itemize and enumerate) and the second and third columns are values relative to each item in the first column. I'm trying to find a solution where I can use lists in a tabular, something like that:

\begin{tabular}{p{.6\linewidth}p{.2\linewidth}p{.2\linewidth}}
items here & values 1 & values 2
\begin{enumerate}
\item First Item &  & \\ \hline
\begin{itemize}
\item From Itemize & value & other value \\
\item Another one & another value & other value 2\\ \hline
\end{itemize}
\item Second from enum & something & value 3 \\ \hline
\end{enumerate}
\end{tabular}


There is such a way to create LaTeX tables?

• You can use lists within a cell, but you must finish the list or lists before moving to the next column or row. You can't switch to the next cell in the middle of a list.
– cfr
Oct 5, 2015 at 1:20
• This is a limitation of the TeX itself? Or its only a matter of no-one wrote a package for that yet?
– Isma
Oct 5, 2015 at 1:24
• I don't know that it is a limit of TeX, no. I doubt it. But it is not 'only' a matter of writing a package. I think you'd have to rewrite the way LaTeX handles lists and tabular material, at least. This would break all kinds of things badly. So I don't think that is practical at all. You can write something to get the output you want, I'm sure. But I don't think it is realistic to do it in this way. But I'm no expert. Maybe somebody will come up with something.
– cfr
Oct 5, 2015 at 3:17
• To be honest, it isn't really clear to me why you'd want to do it this way in any case. You can certainly get numbering and bullets or whatever. So much is straightforward. Apart from that, the lists do some spacing things, but that seems an unhealthy thing to do in the context of a tabular. You want one thing controlling the spacing and alignment here otherwise you'll end up with a mess. So I think not using lists will also give you better results, as well as being much more realistic in terms of what's possible/practicable.
– cfr
Oct 5, 2015 at 3:21
• @cfr I have an idea i'll post it ;-) Oct 5, 2015 at 17:19

Here is a solution:

a new environment mttabular is defined, inside it \item is redefined to do what the OP need using \parbox (one can use minipage this may give more flexibility regarding tabular option e.g. m{length}).

mttabular environment expect 2 arguments : width of 2 last columns, the width of the first column is calculated in function of this two.

\documentclass{article}
\makeatletter
\newenvironment{mttabular}[2]{%
\let\mtitem\item%
\def\item##1&##2&##3\\{%
\mtitem
\parbox[t]{\dimexpr\linewidth-2\tabcolsep-#1-#2\relax}{##1}%
\hfill\parbox[t]{#1}{##2}%
\hfill\parbox[t]{#2}{##3}}%
}%
{\relax}
\makeatother
\begin{document}
bla bla
\begin{mttabular}{.15\textwidth}{.15\textwidth}
\begin{enumerate}
\item First Item &  & \\
\item First Item &  & \\
\begin{itemize}
\item From Itemize & value & other value \\
\item Another one & another value & other value 2\\
\end{itemize}
\item Second from enum & something & value 3 \\
\end{enumerate}
\end{mttabular}
\end{document}


• Nice answer! It is almost what I need. This works well for the example that I put in the question but, what if I need more columns? Or perhaps separate some columns using a vertical line? Or rows using horizontal lines? This is the main reason why I would like to use a tabular.
– Isma
Oct 5, 2015 at 18:40
• @Isma well, this is just an idea you can improve it to fil your need. I think it diffecult to allow arbitrary number of columns, vertical separation too, (unless another approch) \hline can be defined as \hrule.If you give more informations about what do you really need you are welcome, i'll try again, otherwise I am not a package writer :-). Oct 5, 2015 at 19:22
• Sorry, I didn't mean to offend. I'm just looking for a solution that could work for people with slight different needs from my own. I can use your solution for my current needs, and I'm thankful for that! If I find a more embracing solution I'll post here. Otherwise I'll accept yours as solution.
– Isma
Oct 5, 2015 at 19:32
• @Isma no need to apologize, as I said, you're welcome. what I mean I'm not looking for a generic solution, that can be expensive and useless. Oct 5, 2015 at 19:41
• This is very nice. I think a generic solution would be expensive, whereas variations on this solution could be had quite cheaply. Cheapness is good!
– cfr
Oct 5, 2015 at 20:30