表格单元格中的枚举会在右下角中断表格

表格单元格中的枚举会在右下角中断表格

因此,我在文本用例表中编写了一个枚举,但问题似乎是右下角的表格被破坏了。以下是该问题的屏幕截图:

在此处输入图片描述

我使用的乳胶代码如下:

\begin{center}
\rowcolors{2}{white}{white}
\begin{longtable}{ | p{4cm} p{8cm} | }
    \hline
    \rowcolor{gray!10}
    \multicolumn{2}{| l |}{\textbf{Use Case: UserAccess}}\\
    \hline
    \rowcolor{gray!25}
    \textbf{Element} & \textbf{Description}\\
    \hline
    ID & Use Case 1\\
    Description & Users must securely login to use the program\\
    Primary Actors & Network Administrator\\
    Secondary Actors & None\\
    Preconditions & The user has access defined by the secure access policy\\
    Main Flow &
    \begin{enumerate}
        \item{User inputs login details}
        \item{\textbf{Include: Authenticate}}
        \item{If details are incorrect, user is asked to re-enter details}
    \end{enumerate}\\
    Postconditions & User is granted access to program\\
    Alternate Flows: None\\
    \hline
\end{longtable}
\end{center}

答案1

此外,在枚举环境中,行的顶部和底部会出现不必要的水平和垂直间距。下面介绍如何使用 来避免这些间距enumitem。不是说您不应该center对表格使用 环境,而是应该使用\centering指令,而且对于长表格,您不应该使用 指令,因为长表格会自动居中。

\documentclass{article}
\usepackage{longtable,array,lipsum}
\usepackage{enumitem}
\usepackage[table]{xcolor}

\begin{document}

\setlength{\extrarowheight}{3pt}
\begin{longtable}{ | p{4cm}p{8cm}|}
  \hline
  \rowcolor{gray!10}
  \multicolumn{2}{| l |}{\textbf{Use Case: UserAccess}} \\
  \hline
  \rowcolor{gray!25}
  \textbf{Element} & \textbf{Description} \\
  \hline
  ID & Use Case 1 \\
  Description & Users must securely login to use the program \\
  Primary Actors & Network Administrator \\
  Secondary Actors & None \\
  Preconditions & The user has access defined by the secure access policy \\
  Main Flow &
  \begin{enumerate}[wide = 0pt, leftmargin = *, nosep, itemsep = 2pt, before = \vspace*{-\baselineskip}, after =\vspace*{-\baselineskip} ]
    \item{User inputs login details}
    \item{\textbf{Include: Authenticate}}
    \item{If details are incorrect, user is asked to re-enter details}
  \end{enumerate} \\
  Postconditions & User is granted access to program \\
  Alternate Flows: None & \\
  \hline
\end{longtable}

\end{document} 

在此处输入图片描述

相关内容