我想在表格的一列中使用多行项目列表,但是它不起作用。它说缺少 \item 但是它之前已经结束了。
\documentclass[a4paper,10pt]{article}
\usepackage[a4paper, top=2cm, bottom=2cm, left=2.5cm, right=1cm]{geometry}
\usepackage{lastpage}
\usepackage[utf8]{inputenc}
\usepackage{array,multirow}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{setspace}
\usepackage[table]{xcolor}
%definir a fonte a utilizar
\usepackage{times}
\renewcommand{\familydefault}{\sfdefault}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\vspace{0.5cm}
\noindent
\tabulinesep=1.5ex
\begin{tabu} to \linewidth {|X[m,c]|X[m,c]|X[m,c]}
\cline{0-1}
Autorizado & & \multirow{2}{*}{
\begin{description}
\item[First] The first item
\item[Second] The second item
\item[Third] The third etc \ldots
\end{description}
}\\\cline{0-1}
Não Autorizado & \\\cline{0-1}
\end{tabu}
\end{document}`
更新 我已经使用一个框完成了此操作,但现在我遇到了另一个问题。表格垂直对齐到中间 (m),而在此单元格中我需要将其对齐到顶部。不是框,而是多行。
\documentclass[a4paper,10pt]{article}
\usepackage[a4paper, top=2cm, bottom=2cm, left=2.5cm, right=1cm]{geometry}
\usepackage{lastpage}
\usepackage[utf8]{inputenc}
\usepackage{array,multirow}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{setspace}
\usepackage[table]{xcolor}
%definir a fonte a utilizar
\usepackage{times}
\renewcommand{\familydefault}{\sfdefault}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\vspace{0.5cm}
\noindent
\tabulinesep=1.5ex
\begin{tabu} to \linewidth {|X[m,c]|X[m,c]|X[m,c]}
\cline{0-1}
Autorizado & & \multirow{2}{*}{
\parbox[t][][t]{4cm}{
\small
\begin{description}
\item[First] The first item
\item[Second] The second item
\item[Third] The third etc \ldots
\end{description}
}
}\\\cline{0-1}
Não Autorizado & \\\cline{0-1}
\end{tabu}
\end{document}
答案1
我一直在思考你的问题。你为什么想要在单元description
格内放置一个tabu
?!如果你的答案是“将它放在表格旁边”或“我使用它来tabu
对齐文本”,请考虑以下替代方案。输出看起来一样,但需要的修改要少得多。
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, top=2cm, bottom=2cm, left=2.5cm, right=1cm]{geometry}
\usepackage{enumitem}
\usepackage{tabu}
\begin{document}
\noindent
\tabulinesep=1.5ex
\begin{tabu} to 0.66\linewidth [t] {|X[m,c]|X[m,c]|}
\firsthline
Autorizado & \\
\hline
Não Autorizado & \\
\hline
\end{tabu}
\begin{minipage}[t]{\hsize}
\begin{description}[itemsep=0pt,parsep=0pt]
\item[First] The first item
\item[Second] The second item
\item[Third] The third etc \ldots
\end{description}
\end{minipage}
\end{document}
答案2
description
您可以在 中设置minipage
;借助 ,enumitem
您可以删除项目之间的空间(如果需要)。无需猜测小页面的宽度,因为您可以使用\hsize
。
请注意,我删除了m
第三列中的说明符,否则您将永远无法获得顶部对齐。
这是一个罕见的能够获益的案例\multirow
,虽然目的不是很清楚。
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, top=2cm, bottom=2cm, left=2.5cm, right=1cm]{geometry}
\usepackage{array,multirow,enumitem}
\usepackage{longtable}
\usepackage{tabu}
\begin{document}
\noindent
\tabulinesep=1.5ex
\begin{tabu} to \linewidth {|X[m,c]|X[m,c]|X}
% some cells to show the effect
\hline
A & B & C \\
\hline
% now an empty row
\multicolumn{3}{c}{} \\
% here starts your table
\cline{0-1}
Autorizado & & \multirow{2}{*}{%
\begin{minipage}[t]{\hsize}
\begin{description}[itemsep=0pt,parsep=0pt]
\item[First] The first item
\item[Second] The second item
\item[Third] The third etc \ldots
\end{description}
\end{minipage}%
}\\\cline{0-1}
Não Autorizado & \\\cline{0-1}
\end{tabu}
\end{document}
答案3
供参考,您可以在{description}
中\Block
放入{NiceTabular}
。nicematrix
\documentclass[a4paper,10pt]{article}
\usepackage[a4paper, top=2cm, bottom=2cm, left=2.5cm, right=1cm]{geometry}
\usepackage{nicematrix,xcolor,enumitem}
\begin{document}
\renewcommand{\arraystretch}{1.4}
\noindent
\begin{NiceTabular}{|X[m,c]|X[m,c]|X[m,c]}
\cline{1-2}
Autorizado & &
\Block{2-1}
{
\begin{description}[itemsep=0pt,parsep=0pt]
\item[First] The first item
\item[Second] The second item
\item[Third] The third, etc.
\end{description}
}
\\
\cline{1-2}
Não Autorizado \\
\cline{1-2}
\end{NiceTabular}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。