我想在多行的单列表中包含文本,但我需要enumerate
在一个单元格中包含一个。我收到错误,并在互联网上看到问题出在将环境与 组合在一起时\item
。有解决方案吗?我还没有找到任何东西。
样本:
...
\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}
...
错误:
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: )
答案1
尝试将标题更改p{3cm}
为如下所示:
\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}
答案2
查看listliketab包列表列
以下内容很久以前由 Donald Arseneau 在 CTT 上发布,用于逐项和枚举单元格
\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}