当“列表”是表格单元格内表格环境的一部分时,如何删除“描述”后的空行

当“列表”是表格单元格内表格环境的一部分时,如何删除“描述”后的空行

使用 \usepackage{longtable} 创建表格。除每行最后一个单元格外,所有单元格都是简单单元格。此单元格包含另一个表格环境。它包含几行文本和一个列表。无论我做什么,都无法摆脱列表后的空行(参见“第二行”)。但是,有一个例外。如果我在列表后放一行文本,就不会得到空行。请参阅“第一行”。

问题:什么是神奇命令可以删除“列表”后的空行?

\documentclass[letterpaper]{article}

\usepackage{longtable}
\usepackage{enumitem}

\begin{document}
\begin{longtable}{@{}lcccl@{}}
  \caption{INPUT ports definition.} \label{tab:signal_definition_input} \\
  \hline
  \textbf{COL 1} & \textbf{COL 2} & \textbf{COL 3} 
          & \textbf{COL 4}& \textbf{DESCRIPTION}  \\
  \hline
  \endfirsthead

  \multicolumn{5}{c}%
  {{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\    
  \hline
  \textbf{COL 1} & \textbf{COL 2} & \textbf{col 3}  
  & \textbf{COL 4}& \textbf{DESCRIPTION}  \\
  \hline
  \endhead

  \hline
  \multicolumn{5}{@{}r@{}}{{Continued\ldots}} \\
  \hline
  \endfoot

  \hline 
  \endlastfoot

  first row  & 1 & IN &  0  & \begin{tabular}{p{8cm}}
                               forces exit from the passthrough mode  \\
                               SOURCE main digital
                               \begin{description}[noitemsep,topsep=0pt]  
                                  \item[0 =]do nothing This is pdfTeX,
                                              Version 3.14159265-2.6-1.40.17 
                                  \item[1 =] force some text and more of the 
                                             same text some text and more 
                                                  of the same text
                                                  within the 'list'
                               \end{description}
                               EXTRA line of text after 'list' is needed
                               to prevent empty line                 \\
                               \end{tabular}                         \\ 
  \hline %-----------------------------------------------  
  second row & 1 & IN &  0  & \begin{tabular}{p{8cm}}
                               forces exit from the passthrough mode  \\
                               SOURCE main digital
                               \begin{description}[noitemsep,topsep=2pt]  
                                  \item[0 =]do nothing This is pdfTeX,
                                            Version 3.14159265-2.6-1.40.17  
                                  \item[1 =] force some text and more of the 
                                             same text some text and more 
                                             of the same text
                                             within the 'list' 
                              \end{description}
                              \end{tabular}                   \\
  \hline %------------------------------------------------
\end{longtable}

\end{document}

单元格内的表格环境中的列表

答案1

有多种方法可以实现悬挂缩进。请注意,\baselineskip不适用于 的第一行或最后一行\parbox,因此我喜欢以 开始和结束\strut

\documentclass[letterpaper]{article}

\usepackage{longtable}
\usepackage{enumitem}

\newcommand{\desc}[2]% %1 = label, #2 = description
{\bgroup
  \sbox0{#1\hspace{\itemsep}}%
  \usebox0\parbox[t]{\dimexpr \linewidth-\wd0}{\strut #2\strut}%
\egroup}

\begin{document}
\begin{longtable}{@{}lcccl@{}}
  \caption{INPUT ports definition.} \label{tab:signal_definition_input} \\
  \hline
  \textbf{COL 1} & \textbf{COL 2} & \textbf{COL 3} 
          & \textbf{COL 4}& \textbf{DESCRIPTION}  \\
  \hline
  \endfirsthead

  \multicolumn{5}{c}%
  {{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\    
  \hline
  \textbf{COL 1} & \textbf{COL 2} & \textbf{col 3}  
  & \textbf{COL 4}& \textbf{DESCRIPTION}  \\
  \hline
  \endhead

  \hline
  \multicolumn{5}{@{}r@{}}{{Continued\ldots}} \\
  \hline
  \endfoot

  \hline 
  \endlastfoot

  first row  & 1 & IN &  0  & \parbox{8cm}{\strut
                               forces exit from the passthrough mode  \\
                               SOURCE main digital\\
                               \desc{0 =}{do nothing This is pdfTeX,
                                              Version 3.14159265-2.6-1.40.17}\\
                               \desc{1 =}{force some text and more of the 
                                             same text some text and more 
                                                  of the same text
                                                  within the 'list'}%
                               \strut}\\ 
  \hline %-----------------------------------------------  
  second row & 1 & IN &  0  & \parbox{8cm}{\strut
                               forces exit from the passthrough mode  \\
                               SOURCE main digital\\
                               \desc{0 =}{do nothing This is pdfTeX,
                                            Version 3.14159265-2.6-1.40.17}\\
                               \desc{1 =}{force some text and more of the 
                                             same text some text and more 
                                             of the same text
                                             within the 'list'}%
                              \strut}\\
  \hline %------------------------------------------------
\end{longtable}

\end{document}

演示

答案2

只需在最后一项行中添加此命令: \vspace{-\baselineskip}\mbox{} 编辑:将其添加到 \end{description} 之前,如下所示:

                      \begin{description}[noitemsep,topsep=0pt]  
                          \item[0 =]do 
                          \item[1 =]   within the 'list''\vspace{-\baselineskip}\mbox{}
                       \end{description}

相关内容