我正在尝试创建一个表格,其中最后一列有一个无序列表。下面的代码的问题是它会跳过该列中每个单元格的一行,就像下图一样。我怎样才能创建没有跳过那行的表格?
\documentclass{article}
\usepackage[margin=2.3cm]{geometry}
\begin{document}
\centering
{\renewcommand{\arraystretch}{2}
\begin{tabular}{ p{35mm} p{20mm} p{20mm} p{20mm} p{25mm} p{45mm}}
\hline
& \centering Column \newline Number 2 & \centering Column \newline Number 3 & \centering Column \newline Number 4 & \centering Column \newline Number 5 & Column \newline Number 6 \\
\hline
entry1 & \centering entry2 & \centering entry3 & \centering entry4 & \centering entry5 & \begin{itemize} \item entry6.1 \item entry6.2 \end{itemize} \\
entry1 & \centering entry2 & \centering entry3 & \centering entry4 & \centering entry5 & \begin{itemize} \item entry6.1 \item entry6.2 \end{itemize} \\
\hline
\end{tabular}
\end{document}
答案1
一些改进和简化(来自@Stefan Kottwitz 的代码):
\documentclass{article}
\usepackage[margin=2.3cm]{geometry}
\usepackage{enumitem, etoolbox, tabularx, makecell, booktabs}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\begin{document}
\centering
{\renewcommand{\arraystretch}{2}
\setlist[itemize]{wide=0pt, leftmargin=*, topsep=0pt, after=\vspace*{-\baselineskip}}
\AtBeginEnvironment{itemize}{\compress}
\begin{tabularx}{\linewidth}{X *{3}{p{20mm}} p{25mm}p{45mm}}
\toprule
& \thead{Column \\ Number 2} & \thead{Column \\ Number 3} & \thead{Column \\ Number 4} & \thead{Column \\ Number 5} & \thead{Column \\ Number 6} \\
\midrule
entry1 & \centering entry2 & \centering entry3 & \centering entry4 & \centering entry5 & \begin{itemize} \item entry6.1 \item entry6.2 \end{itemize}
\\
entry1 & \centering entry2 & \centering entry3 & \centering entry4 & \centering entry5 &\begin{itemize} \item entry6.1 \item entry6.2 \end{itemize} \\
\bottomrule
\end{tabularx}}
\end{document}
答案2
\documentclass{article}
\usepackage[margin=2.3cm]{geometry}
\begin{document}
\centering
{\renewcommand{\arraystretch}{2}
\begin{tabular}{ p{35mm} p{20mm} p{20mm} p{20mm} p{25mm} p{45mm}}
\hline
& \centering Column \newline Number 2 & \centering Column \newline Number 3 & \centering Column \newline Number 4 & \centering Column \newline Number 5 & Column \newline Number 6 \\
\hline
entry1 & \centering entry2 & \centering entry3 & \centering entry4 & \centering entry5 & \makeatletter\@minipagetrue\begin{itemize} \item entry6.1 \item entry6.2 \end{itemize} \\
entry1 & \centering entry2 & \centering entry3 & \centering entry4 & \centering entry5 & \makeatletter\@minipagetrue\begin{itemize} \item entry6.1 \item entry6.2 \end{itemize} \\
\hline
\end{tabular}}
\end{document}