删除表格列表后的空格,但 \vspace 没有给出结果

删除表格列表后的空格,但 \vspace 没有给出结果

如你看到的这里在项目 1、项目 2 和项目 3 之后,有一个垂直空格,我想将其删除。

这是我的 MWE:

\documentclass{book}
\usepackage{longtable, array,enumitem, booktabs}
\newcolumntype{P}[1]{>{\endgraf\vspace*{-\baselineskip}}p{#1}}
\begin{document}
        \renewcommand{\arraystretch}{1.5}
        \begin{center}
            \begin{longtable}{p{2cm}P{11cm}}
                \caption{\label{tab}This is a table}\\
                \toprule
                \multicolumn{1}{c}{\parbox[H]{2cm}{\centering \textbf{Column 1}}}
                & \multicolumn{1}{c}{\parbox[H]{11cm}{\centering \textbf{Column 2}}}\\
                \hline \hline
                \endfirsthead
                \hline
                \multicolumn{1}{c}{\parbox[H]{2cm}{\centering Column 1}}
                & \multicolumn{1}{c}{\parbox[H]{11cm}{\centering Column 2}}\\
                \hline \hline
                \endhead 
                Point 1 & 
                \begin{itemize}[noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt, nosep]
                    \item ITEM 1
                    \item ITEM 2
                    \item ITEM 3
                \end{itemize}
            \vspace{-2cm} \\     
                \hline
                Point 2 & Explanation  \\
                \hline
                Point 3 & Explanation \\
                \hline
                Point 4 & Explanation \\
                \bottomrule
            \end{longtable}
        \end{center}
\end{document}

答案1

我建议定义一个自己的自定义列表,用于表格单元格。在下面的 MWE 中,我还更正了第二个单元格的宽度,以确保表格不超过文本宽度。关于第一个 rwo:这里不需要任何\centeringno 。您也已经使用过的简单方法将其内容水平居中。\parbox\multicolumn{c}

在此处输入图片描述

\documentclass{book}
\usepackage{longtable, array,enumitem, booktabs}

\newlist{tabitem}{itemize}{1}
\setlist[tabitem]{label=\textbullet, noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt, nosep, before=\begin{minipage}[t]{\hsize}, after=\end{minipage}}

\begin{document}
        \renewcommand{\arraystretch}{1.5}
            \begin{longtable}{p{2cm}p{\dimexpr\textwidth-2cm-4\tabcolsep}}
                \caption{\label{tab}This is a table}\\
                \toprule
                \multicolumn{1}{c}{\textbf{Column 1}}
                & \multicolumn{1}{c}{\textbf{Column 2}}\\
                \hline \hline
                \endfirsthead
                \hline
                \multicolumn{1}{c}{\textbf{Column 1}}
                & \multicolumn{1}{c}{\textbf{Column 2}}\\
                \hline \hline
                \endhead 
                Point 1 & 
                \begin{tabitem}
                    \item ITEM 1
                    \item ITEM 2
                    \item ITEM 3
                \end{tabitem}\\     
                \hline
                Point 2 & Explanation  \\
                \hline
                Point 3 & Explanation \\
                \hline
                Point 4 & Explanation \\
                \bottomrule
            \end{longtable}
\end{document}

这也是仅使用包中的水平线的第二种变体booktabs

在此处输入图片描述

\documentclass{book}
\usepackage{longtable, array,enumitem, booktabs}

\newlist{tabitem}{itemize}{1}
\setlist[tabitem]{label=\textbullet, noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt, nosep, before=\begin{minipage}[t]{\hsize}, after=\end{minipage}}

\begin{document}
            \begin{longtable}{p{2cm}p{\dimexpr\textwidth-2cm-4\tabcolsep}}
                \caption{\label{tab}This is a table}\\
                \toprule
                \multicolumn{1}{c}{\textbf{Column 1}}
                & \multicolumn{1}{c}{\textbf{Column 2}}\\
                \midrule
                \endfirsthead
                \hline
                \multicolumn{1}{c}{\textbf{Column 1}}
                & \multicolumn{1}{c}{\textbf{Column 2}}\\
                \midrule
                \endhead 
                \bottomrule
                \endfoot
                Point 1 & 
                \begin{tabitem}
                    \item ITEM 1
                    \item ITEM 2
                    \item ITEM 3
                \end{tabitem}\\     
               \midrule
                Point 2 & Explanation  \\
               \midrule
                Point 3 & Explanation \\
               \midrule
                Point 4 & Explanation \\
                
            \end{longtable}         
            
\end{document}

相关内容