如何在 longtable 环境中删除单元格填充?

如何在 longtable 环境中删除单元格填充?

我有一张跨多页的表格。因此,我自然而然地使用了longtable横向模式的环境。

表格工作正常,但输出有大量垂直单元格填充,有时会导致一页只有一行。任何有关如何删除它们并使下表看起来可接受的帮助。

\begin{landscape}
\begin{longtable}{|m{3.0cm}|m{8.5cm}|m{8.5cm}|}
\hline
Algorithm & Advantages & Disadvantages \\
\hline
Method A &\begin{itemize}
    \item Have a variable history window controlled by the weight parameter.
     \item Resilient to noise and impurities in data.
\end{itemize} & \begin{itemize}
    \item Difficult to gauge the sensitivity of the weight parameter.
     \item Has a tendency to loose pattern information during averaging.
\end{itemize}\\
\hline
Method B &  \begin{itemize}
    \item Fixed number of pervious input vectors provide fine grain control over the amount of history the algorithm considers when making classifications.  
     \item Does not loose pattern information as in averaging.
\end{itemize} & \begin{itemize}
    \item Is not very resilient to noise or impurities in data.
     \item Increasing the number of previous input vectors appended to the current input vector will increase the dimensionality (curse of dimensionality) of the overall input vector and the weight vectors of the SOM.
\end{itemize}\\
\hline
\caption{Summary of Methods}
\label{tab:summaryAlgorithms}    
\end{longtable}
\end{landscape}

以下是上述代码的输出(我想确保没有垂直填充)

enter image description here

答案1

看看,这是否是你想要的:

enter image description here

上图的代码包含一些技巧,其中一个是“借用”的这里...

\documentclass{article}
    \usepackage{array,longtable,multirow}
    \usepackage{caption}
    \usepackage{paralist}
    \usepackage[margin=20mm]{geometry}

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother    

\newcolumntype{P}[1]{>{\compress\vspace{-2ex}}p{#1}<{\vspace*{-2ex}}}  
    \begin{document}
\begin{longtable}{|l|P{72mm}
                    |P{72mm}|}%
\hline
Algorithm & Advantages & Disadvantages \\
\hline
\multirow{5}*{Method A}
        &   \begin{itemize}
            \item Have a variable history window controlled by the weight parameter.
            \item Resilient to noise and impurities in data.
                \end{itemize}
                &   
                    \begin{itemize}[\textbullet]
                \item Difficult to gauge the sensitivity of the weight parameter.
                \item Has a tendency to loose pattern information during averaging.
                    \end{itemize}\\
\hline
\caption{Summary of Methods}
\label{tab:summaryAlgorithms}
\end{longtable}
    \end{document}    \caption{Summary of Methods}
\label{tab:summaryAlgorithms}
\end{longtable}
    \end{document}

该包用于垂直居中第一个表格列的内容multirow。行数大约等于此行中其他单元格中最高单元格的行数(在示例 4 中,但 5 给出的结果略好一些)。

由于landscape与你的问题无关,我跳过了它。带有列表的列之间略有不同。第二个是漏洞利用paralist包,其中使用选项时textbullet列表会移近列的左边界。

附录:您可以使用包获得更好的外观(根据我的口味)makecell,通过使用宏thead您可以获得:

enter image description here

\documentclass{article}
    \usepackage{array,longtable,makecell,multirow}
\newcolumntype{P}[1]{>{\compress\vspace{-2ex}}p{#1}<{\vspace*{-2ex}}}
\renewcommand\theadfont{\bfseries}
    \usepackage{caption}
    \usepackage{paralist}
    \usepackage[margin=20mm]{geometry}

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother    

    \begin{document}
\begin{longtable}{|l|P{72mm}
                    |P{72mm}|}%
\hline
\thead{Algorithm} & \thead{Advantages} & \thead{Disadvantages} \\
\hline
\multirow{5}*{Method A} 
            &   \begin{itemize}[\textbullet]
            \item Have a variable history window controlled by the weight parameter.
            \item Resilient to noise and impurities in data.
                \end{itemize}
                &   
                    \begin{itemize}[\textbullet]
                \item Difficult to gauge the sensitivity of the weight parameter.
                \item Has a tendency to loose pattern information during averaging.
                    \end{itemize}\\
\hline
\caption{Summary of Methods}
\label{tab:summaryAlgorithms}
\end{longtable}
    \end{document}

相关内容