我正在使用以下代码来生成表格。
\documentclass[acmsmall]{acmart}
\begin{document}
\begin{table}[!t]
\renewcommand{\arraystretch}{1.3}
\caption{Some text}
\centering
\begin{tabular}{|p{8.3cm}|p{1.7cm}|p{1.7cm}|}
\hline
\textbf{Some text} & \textbf{Some text} & \textbf{Some text} \\
\hline
\textbf{Some text:}
\begin{itemize}
\item Some text
\item Some text
\item Some text
\end{itemize}
&
43\%{$\newline$}
\checkmark{$\newline$}
-{$\newline$}
-{$\newline$}
&
57\%{$\newline$}
-{$\newline$}
\checkmark{$\newline$}
\checkmark{$\newline$}
\\
\hline
\textbf{Some text}
\begin{itemize}
\item Some text
\item Some text
\item Some text
\item Some text
\end{itemize}
&
25\%{$\newline$}
\checkmark{$\newline$}
-{$\newline$}
-{$\newline$}
-{$\newline$}
&
75\%{$\newline$}
-{$\newline$}
\checkmark{$\newline$}
\checkmark{$\newline$}
\checkmark{$\newline$}
\\
\hline
\textbf{Some text:}
\begin{itemize}
\item Some text
\item Some text
\end{itemize}
&
0\%{$\newline$}
-{$\newline$}
-{$\newline$}
&
100\%{$\newline$}
\checkmark{$\newline$}
\checkmark{$\newline$}
\\
\hline
\end{tabular}
\label{table1}
\end{table}
\end{document}
但是,如下图所示,表格中有空白处(黄色突出显示)。我想知道是否有办法从表格中删除这些多余的行?
如果需要的话我很乐意提供任何其他详细信息:)
答案1
放在\vspace*{-\baselineskip}
每个项目后面并删除{$\newline$}
每列的最后一列。
\documentclass[acmsmall]{acmart}
\begin{document}
\begin{table}[!t]
\renewcommand{\arraystretch}{1.3}
\caption{Some text}
\centering
\begin{tabular}{|p{8.3cm}|p{1.7cm}|p{1.7cm}|}
\hline
\textbf{Some text} & \textbf{Some text} & \textbf{Some text} \\
\hline
\textbf{Some text:}
\begin{itemize}
\item Some text
\item Some text
\item Some text
\end{itemize}
\vspace*{-\baselineskip}
&
43\%{$\newline$}
\checkmark{$\newline$}
-{$\newline$}
-
&
57\%{$\newline$}
-{$\newline$}
\checkmark{$\newline$}
\checkmark
\\
\hline
\textbf{Some text}
\begin{itemize}
\item Some text
\item Some text
\item Some text
\item Some text
\end{itemize}
\vspace*{-\baselineskip}
&
25\%{$\newline$}
\checkmark{$\newline$}
-{$\newline$}
-{$\newline$}
-
&
75\%{$\newline$}
-{$\newline$}
\checkmark{$\newline$}
\checkmark{$\newline$}
\checkmark
\\
\hline
\textbf{Some text:}
\begin{itemize}
\item Some text
\item Some text
\end{itemize}
\vspace*{-\baselineskip}
&
0\%{$\newline$}
-{$\newline$}
-
&
100\%{$\newline$}
\checkmark{$\newline$}
\checkmark
\\
\hline
\end{tabular}
\label{table1}
\end{table}
\end{document}
这里有一个建议,如何以更有吸引力的方式格式化此表格。
\documentclass[acmsmall]{acmart}
\usepackage{booktabs}
\begin{document}
\begin{table}[!t]
\caption{Some text}
\centering
\begin{tabular}{@{}lcc@{}}
\toprule
\textbf{Some text} & \textbf{Some text} & \textbf{Some text} \\
\midrule
\textbf{Some text:} & 43\% & 57\% \\
Some text & \checkmark & --- \\
Some text & --- & \checkmark \\
Some text & --- & \checkmark \\
\addlinespace
\textbf{Some text} & 25\% & 75\% \\
Some text & \checkmark & --- \\
Some text & --- & \checkmark \\
Some text & --- & \checkmark \\
Some text & --- & \checkmark \\
\addlinespace
\textbf{Some text:} & 0\% & 100\% \\
Some text & --- & \checkmark \\
Some text & --- & \checkmark \\
\bottomrule
\end{tabular}
\label{table1}
\end{table}
\end{document}
答案2
两个建议:
将每个
itemize
环境放入顶部对齐的minipage
环境中{$\newline$}
省略每组中的最终指令
可选:删除指令\renewcommand{\arraystretch}{1.3}
并添加\setlength\extrarowheight{2pt}
。
\documentclass[acmsmall]{acmart}
\usepackage{array}
%\usepackage{enumitem}
%\setlist[itemize]{nosep}
\begin{document}
\begin{table}[!t]
%\renewcommand{\arraystretch}{1.3}
\setlength\extrarowheight{2pt}
\caption{Some text}
\label{table1}
\centering
\begin{tabular}{|p{8.3cm}|p{1.7cm}|p{1.7cm}|}
\hline
\textbf{Some text} & \textbf{Some text} & \textbf{Some text}
\\ \hline
%% 1st group
\textbf{Some text:} & 43\% & 57\% \\
\begin{minipage}[t]{\hsize}
\begin{itemize}
\item Some text
\item Some text
\item Some text
\end{itemize}
\end{minipage}
&
\checkmark{$\newline$}
--{$\newline$}
--%{$\newline$}
&
--{$\newline$}
\checkmark{$\newline$}
\checkmark%{$\newline$}
\\ \hline
%% 2nd group
\textbf{Some text} & 25\% & 75\%\\
\begin{minipage}[t]{\hsize}
\begin{itemize}
\item Some text
\item Some text
\item Some text
\item Some text
\end{itemize}
\end{minipage}
&
\checkmark{$\newline$}
--{$\newline$}
--{$\newline$}
--%{$\newline$}
&
--{$\newline$}
\checkmark{$\newline$}
\checkmark{$\newline$}
\checkmark%{$\newline$}
\\ \hline
%% 3rd group
\textbf{Some text:} & 0\% & 100\% \\
\begin{minipage}[t]{\hsize}
\begin{itemize}
\item Some text
\item Some text
\end{itemize}
\end{minipage}
&
--{$\newline$}
--%{$\newline$}
&
\checkmark{$\newline$}
\checkmark%{$\newline$}
\\ \hline
\end{tabular}
\end{table}
\end{document}