Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to have text in one column table with multiple rows, but I need to include an enumerate in one cell. I get errors and read on the Internet the problem is in combining environments with \item. Is there a solution? I haven't found anything yet.

Sample:

...
\begin{tabular}{|l|}
\hline
\textbf{Name:} Foo \\
\hline
\textbf{Main success scenario:} \\ 
\begin{enumerate}
  \item Entry action
  \item next steps\ldots
\end{enumerate}
\hline
\end{tabular}
 ...

Errors:

Illegal unit of measure (pt inserted). \hline (followed by: )   
Misplaced \noalign. \hline (followed by: )  
Missing number, treated as zero. \hline (followed by: ) 
Something's wrong--perhaps a missing \item. \end{enumerate} (followed by: ) 
You can't use `\hrule' here except with leaders. \hline (followed by: )
share|improve this question
1  
Could you please add some sample code what exactly you are trying and what the error message is. That makes it easier to help you. –  Caramdir Feb 20 '11 at 1:17
1  
See also these questions for examples and solutions on lists inside tabular: (1), (2), (3) –  Martin Scharrer Feb 20 '11 at 1:25
1  
(You can format code nicely by indenting it with 4 spaces or selecting it and pressing the 101010 button.) –  Caramdir Feb 20 '11 at 1:38
    
@Caramdir thanks –  Gabriel Ščerbák Feb 20 '11 at 1:43

2 Answers 2

up vote 16 down vote accepted

Try changing the heading to p{3cm} as shown below:

\documentclass{article}
\begin{document}
\begin{tabular}{|p{3cm}|}
\hline
\textbf{Name:} Foo \\
\hline
\textbf{Main success scenario:} \\ 
\begin{enumerate}
  \item Entry action
  \item next steps\ldots
\end{enumerate}\\
\hline
\end{tabular}
\end{document}
share|improve this answer
    
Thanks, this is an easy solution that works, meanwhile I found it on the web as well (en.wikibooks.org/wiki/LaTeX/…). However now I would like to avoid absolute width, how to have it adjust to the width of the page or cell content? –  Gabriel Ščerbák Feb 20 '11 at 2:24
    
Ok, I found further information here: en.wikibooks.org/wiki/LaTeX/Tables#The_tabular_environment –  Gabriel Ščerbák Feb 20 '11 at 2:33
    
@YiannisLazarides: Thanks for the answer. Reading about tabular, I could understand the definitions but still not quite get why one could not replace [c] or [l] for that matter with {|p(3cm)|} at the top...it gives an error message –  Abhimanyu Arora Aug 14 at 17:26
1  
@AbhimanyuArora The definition of a list in LaTeX kernel uses paragraphs and paragraph related commands, hence require the |p{}|. The |c| |l| etc cannot accept paragraphs. –  Yiannis Lazarides Aug 14 at 17:36
    
I see, that's great! Thanks for clarifying. –  Abhimanyu Arora Aug 14 at 17:56

Look at the listliketab package list columns

The following was posted on CTT a long time ago by Donald Arseneau for itemized and enumerated cells

\documentclass{article}
\usepackage{array}
\makeatletter
\newcolumntype{e}[1]{%--- Enumerated cells ---
   >{\minipage[t]{\linewidth}%
     \NoHyper%                Hyperref adds a vertical space
     \let\\\tabularnewline
     \enumerate
        \addtolength{\rightskip}{0pt plus 50pt}% for raggedright
        \setlength{\itemsep}{-\parsep}}%
   p{#1}%
   <{\@finalstrut\@arstrutbox\endenumerate
     \endNoHyper
     \endminipage}}

\newcolumntype{i}[1]{%--- Itemized cells ---
   >{\minipage[t]{\linewidth}%
        \let\\\tabularnewline
        \itemize
           \addtolength{\rightskip}{0pt plus 50pt}%
           \setlength{\itemsep}{-\parsep}}%
   p{#1}%
   <{\@finalstrut\@arstrutbox\enditemize\endminipage}}

\AtBeginDocument{%
    \@ifpackageloaded{hyperref}{}%
        {\let\NoHyper\relax\let\endNoHyper\relax}}
\makeatother
\begin{document}

\begin{tabular}[t]{|i{2.5cm}|e{3cm}|}
\hline
  \item Item A
  \item Item B   &
  \item Item 1
  \item Item 2   \\
\hline
\end{tabular}

\end{document} 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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