1

I need a table with a cell containing a very long enumerated list. Here's the code I'm using:

\documentclass{article}
\usepackage[a4paper, margin=1in]{geometry}
\usepackage{longtable}
\usepackage{enumitem}
\setlist[enumerate]{label*=\arabic*.}
\usepackage{array}

\begin{document}

\begin{longtable}{|>{\bfseries}l|p{10cm}|}
  \hline
  \textbf{Document Section} & General Process \\
  \hline
  \textbf{ID} & None \\
  \hline
  \textbf{Participants} & User, System \\
  \hline
  \textbf{Precondition} & \begin{itemize}
  \item The user is not logged in.
  \item The system displays a login screen with fields for "Username" and "Password" and buttons for "Login", "Recover Password", and "Register".
  \end{itemize} \\
  \hline
  \textbf{Process Flow} & \begin{enumerate}
  \item The user clicks the "Register" button.
  \item The system displays a registration form with the button 'Continue' and the fields:
  \begin{itemize}
    \item First Name
    \item Last Name
    \item Birthdate
    \item Gender
    \item Address
    \item Email
    \item Password
    \item Confirm Password
  \end{itemize}
  \item The user fills in the required information and clicks the 'Continue' button.
  \item IF any field is not completed by the user:
  \begin{enumerate}
    \item The system displays an error message: 'Please fill in all fields'.
  \end{enumerate}
  \item OTHERWISE:
  \begin{enumerate}
    \item IF the 'Password' field does not match the 'Confirm Password' field:
    \begin{enumerate}
      \item The system displays an error message: 'Passwords do not match'.
    \end{enumerate}
    \item OTHERWISE:
    \begin{enumerate}
      \item The system performs a syntax check on all fields.
      \item IF all fields are syntactically correct:
      \begin{enumerate}
        \item The system randomly generates a six-digit numeric code.
        \item The system updates the database with the user's information, the generated code, and the current timestamp.
        \item The system sends an email to the provided address containing the generated code.
        \item The system displays a confirmation screen that includes:
        \begin{itemize}
          \item a text box saying: 'Enter the six-digit code you received via email within 30 minutes.'
          \item a six-digit editable field
          \item the button 'Confirm registration'
        \end{itemize}
        \item The user enters the confirmation code in the appropriate field.
        \item The system checks if the confirmation code exists in the database.
        \item IF the confirmation code is not in the database OR the time difference between the current timestamp and the timestamp associated with the code is 30 minutes or more:
        \begin{enumerate}
          \item The system displays an error message: 'Invalid or expired code. Please enter another code or retry the registration process.'
          \item The system returns the user to the confirmation screen.
        \end{enumerate}
        \item OTHERWISE:
        \begin{enumerate}
          \item The system displays a success message: 'Registration successful!'.
          \item The system directs the user to the homepage.
        \end{enumerate}
      \end{enumerate}
    \end{enumerate}
  \end{enumerate}
  \end{enumerate} \\
  \hline
\end{longtable}

\end{document}

However, the table fails to span multiple pages and the enumerated list gets truncated, as you can see from the following screen:

enter image description here

Is there a way to fix this issue, while maintaining the formatting of the enumerated list?

4
  • that table only has one row so can not split over a page. Do not use a table at all here just use a nested list. (almost all tables with two columns of the form lp{...} or lX are better set as a list. Commented May 3 at 21:02
  • tex.stackexchange.com/questions/145234/longtable-with-items/… (and similar answers on this site) Commented May 3 at 21:05
  • @DavidCarlisle, no, the table has multiple rows, the screenshot I attached only shows the problematic row containing the list. Alas, I'm required to use two-columns tables.
    – Maury
    Commented May 4 at 7:08
  • Sorry I missed the first part, sorry yes document has 5 rows, however the issue is the same longtable rows never break across pages Commented May 4 at 8:14

1 Answer 1

2

Table cells can not break over a page, such layouts need to be set as lists. Using enumitem keys you can adjust the styling, increasing the margin of the nested list so that it is a more tabular style not overlapping with Process Flow Or you can take advantage of the space and allow overlap, as here.

I also used `` and '' not " and used a5paper so that it goes over 2 pages in this example.

enter image description here

\documentclass{article}
\usepackage[a5paper, margin=1in]{geometry}
\usepackage{longtable}
\usepackage{enumitem}
\setlist[enumerate]{label*=\arabic*.}
\makeatletter
% allow an extra level of list
\newcounter{enumv}
\renewenvironment{enumerate}[1][]
  {\enit@enumerate\enitdp@enumerate{enum}4{#1}}
  {\enit@endenumerate}
\makeatother
\usepackage{array}

\begin{document}


\begin{description}
\item[Participants] \mbox{}

  User, System
\item[Precondition]\mbox{}
  \begin{itemize}
  \item The user is not logged in.
  \item The system displays a login screen with fields for ``Username'' and ``Password'' and buttons for ``Login'', ``Recover Password'', and ``Register''.
  \end{itemize}
\item[Process Flow]\mbox{}
 \begin{enumerate}
  \item The user clicks the ``Register'' button.
  \item The system displays a registration form with the button 'Continue' and the fields:
  \begin{itemize}
    \item First Name
    \item Last Name
    \item Birthdate
    \item Gender
    \item Address
    \item Email
    \item Password
    \item Confirm Password
  \end{itemize}
  \item The user fills in the required information and clicks the 'Continue' button.
  \item IF any field is not completed by the user:
  \begin{enumerate}
    \item The system displays an error message: 'Please fill in all fields'.
  \end{enumerate}
  \item OTHERWISE:
  \begin{enumerate}
    \item IF the 'Password' field does not match the 'Confirm Password' field:
    \begin{enumerate}
      \item The system displays an error message: 'Passwords do not match'.
    \end{enumerate}
    \item OTHERWISE:
    \begin{enumerate}
      \item The system performs a syntax check on all fields.
      \item IF all fields are syntactically correct:
      \begin{enumerate}
        \item The system randomly generates a six-digit numeric code.
        \item The system updates the database with the user's information, the generated code, and the current timestamp.
        \item The system sends an email to the provided address containing the generated code.
        \item The system displays a confirmation screen that includes:
        \begin{itemize}
          \item a text box saying: 'Enter the six-digit code you received via email within 30 minutes.'
          \item a six-digit editable field
          \item the button 'Confirm registration'
        \end{itemize}
        \item The user enters the confirmation code in the appropriate field.
        \item The system checks if the confirmation code exists in the database.
        \item IF the confirmation code is not in the database OR the time difference between the current timestamp and the timestamp associated with the code is 30 minutes or more:
        \begin{enumerate}
          \item The system displays an error message: 'Invalid or expired code. Please enter another code or retry the registration process.'
          \item The system returns the user to the confirmation screen.
        \end{enumerate}
        \item OTHERWISE:
        \begin{enumerate}
          \item The system displays a success message: 'Registration successful!'.
          \item The system directs the user to the homepage.
        \end{enumerate}
      \end{enumerate}
    \end{enumerate}
  \end{enumerate}
  \end{enumerate}
\end{description} 


\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .