Longtable with multicolumn and parbox spacing issues
There is no need for
\parbox
, column typep
is better regarding the vertical spacing. The width is calculated from the three column width of the defaultp
columns. Each column get two\tabcolsep
, therefore4\tabcolsep
are added for the two suppressed columns.\newlength\mymulticolwidth \setlength{\mymulticolwidth}{\dimexpr 2.5cm + 3.5cm + 2.5cm + 4\tabcolsep\relax}
The example also adds
\extrarowheight
of packagearray
that is added at the top of the rows.The enumerations can be set by environment
enumerate
with some adaptations of Donald Arsenau that defines a new column type and is shown in Danie Els' answer. I have only set\leftmargini
to get rid of the large indentation. If the numbers exceed 9, then the code needs some refinement.
Example file:
\documentclass{article}
\usepackage[
hmargin=15mm,
vmargin=15mm,
]{geometry}
\usepackage{longtable}
\usepackage{array}
\setlength{\extrarowheight}{2pt}
\newlength\mymulticolwidth
\makeatletter
\newcolumntype{e}[1]{%--- Enumerated cells ---
>{\minipage[t]{\linewidth}%
\NoHyper% Hyperref adds a vertical space because of anchor whatsit.
\let\\\tabularnewline
\settowidth{\leftmargini}{9.\hspace{\labelsep}}%
\enumerate
\addtolength{\rightskip}{0pt plus 50pt}% for raggedright
\setlength{\itemsep}{-\parsep}}%
p{#1}%
<{\@finalstrut\@arstrutbox\endenumerate
\endNoHyper
\endminipage}}
\AtBeginDocument{%
\@ifpackageloaded{hyperref}{}%
{\let\NoHyper\relax\let\endNoHyper\relax}}
\makeatother
\begin{document}
\setlength{\mymulticolwidth}{\dimexpr 2.5cm + 3.5cm + 2.5cm + 4\tabcolsep\relax}
\newcommand{\mymulticol}[1]{%
\multicolumn{3}{p{\mymulticolwidth}|}{#1}%
}
\begin{longtable}{| p{3.5cm} | p{2.5cm} | p{3.5cm} | p{2.5cm} |}
\caption{Use case detail}\label{chap3:tab1}\\
\multicolumn{4}{c}{}\\
\endfirsthead
\multicolumn{4}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}}\\
\multicolumn{4}{c}{}\\
\hline
\endhead
\hline \multicolumn{4}{r}{\tablename\ \thetable\ -- \textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
%
\hline
% --------------------------------------------------------------------------------------------------------------
Use Case ID: & \multicolumn{3}{l|}{1}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Use Case Name: & \multicolumn{3}{l|}{FIXME - Section Name}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Created by: & & Date created: &\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Actors & \multicolumn{3}{l|}{Doctor}\\
& \multicolumn{3}{l|}{Patient}\\
& \multicolumn{3}{l|}{Patients' Database}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Description: & \mymulticol{%
The doctor logs into the system, creates/updates the patient medical record, prints the informed consent form and collects it after the patient has signed it.}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Preconditions: & \multicolumn{3}{e{\mymulticolwidth}|}{%
\item The doctor is logged into the web software.
\item There is no record for the patient on the patients' database.}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Postconditions: & \multicolumn{3}{l|}{ }\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Trigger: & \mymulticol{%
The doctor logs in the system and presses the \textit{Login} button}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Normal flow: & \multicolumn{3}{e{\mymulticolwidth}|}{%
\item the doctor clicks on the \textit{Patients} icon;
\item the doctor clicks on the \textit{Add} button;
\item the doctor prints the consent form by clicking on the dedicated button;
\item the doctor fills in the patient's details;
\item the doctor collects the signed patient's consent form and ticks the dedicated check box;
\item the doctor saves the patient's record by clicking the \textit{Save} button.}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Alternative flows: & \multicolumn{3}{l|}{ }\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Exceptions: & \multicolumn{3}{l|}{ }\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Notes and issues: & \multicolumn{3}{l|}{ }\\
% --------------------------------------------------------------------------------------------------------------
\hline
\end{longtable}
\end{document}
The principle can be extended, example for package enumerate
:
\documentclass{article}
\usepackage[
hmargin=15mm,
vmargin=15mm,
]{geometry}
\usepackage{longtable}
\usepackage{array}
\usepackage{enumerate}
\setlength{\extrarowheight}{2pt}
\newlength\mymulticolwidth
\makeatletter
\newcolumntype{e}[1]{%--- Enumerated cells ---
>{\minipage[t]{\linewidth}%
\NoHyper% Hyperref adds a vertical space because of anchor whatsit.
\let\\\tabularnewline
\settowidth{\leftmargini}{9.\hspace{\labelsep}}%
\enumerate
\addtolength{\rightskip}{0pt plus 50pt}% for raggedright
\setlength{\itemsep}{-\parsep}}%
p{#1}%
<{\@finalstrut\@arstrutbox\endenumerate
\endNoHyper
\endminipage}}
\newcolumntype{E}[2]{%--- Enumerated cells ---
>{\minipage[t]{\linewidth}%
\NoHyper% Hyperref adds a vertical space because of anchor whatsit.
\let\\\tabularnewline
\settowidth{\leftmargini}{9a.\hspace{\labelsep}}%
\enumerate[{#2}]%
\addtolength{\rightskip}{0pt plus 50pt}% for raggedright
\setlength{\itemsep}{-\parsep}}%
p{#1}%
<{\@finalstrut\@arstrutbox\endenumerate
\endNoHyper
\endminipage}}
\AtBeginDocument{%
\@ifpackageloaded{hyperref}{}%
{\let\NoHyper\relax\let\endNoHyper\relax}}
\makeatother
\begin{document}
\setlength{\mymulticolwidth}{\dimexpr 2.5cm + 3.5cm + 2.5cm + 4\tabcolsep\relax}
\newcommand{\mymulticol}[1]{%
\multicolumn{3}{p{\mymulticolwidth}|}{#1}%
}
\begin{longtable}{| p{3.5cm} | p{2.5cm} | p{3.5cm} | p{2.5cm} |}
\caption{Use case detail}\label{chap3:tab1}\\
\multicolumn{4}{c}{}\\
\endfirsthead
\multicolumn{4}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}}\\
\multicolumn{4}{c}{}\\
\hline
\endhead
\hline \multicolumn{4}{r}{\tablename\ \thetable\ -- \textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
%
\hline
% --------------------------------------------------------------------------------------------------------------
Use Case ID: & \multicolumn{3}{l|}{1}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Use Case Name: & \multicolumn{3}{l|}{FIXME - Section Name}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Created by: & & Date created: &\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Actors & \multicolumn{3}{l|}{Doctor}\\
& \multicolumn{3}{l|}{Patient}\\
& \multicolumn{3}{l|}{Patients' Database}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Description: & \mymulticol{%
The doctor logs into the system, creates/updates the patient medical record, prints the informed consent form and collects it after the patient has signed it.}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Preconditions: & \multicolumn{3}{e{\mymulticolwidth}|}{%
\item The doctor is logged into the web software.
\item There is no record for the patient on the patients' database.}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Postconditions: & \multicolumn{3}{l|}{ }\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Trigger: & \mymulticol{%
The doctor logs in the system and presses the \textit{Login} button}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Normal flow: & \multicolumn{3}{e{\mymulticolwidth}|}{%
\item the doctor clicks on the \textit{Patients} icon;
\item the doctor clicks on the \textit{Add} button;
\item the doctor prints the consent form by clicking on the dedicated button;
\item the doctor fills in the patient's details;
\item the doctor collects the signed patient's consent form and ticks the dedicated check box;
\item the doctor saves the patient's record by clicking the \textit{Save} button.}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Alternative flows: & \multicolumn{3}{E{\mymulticolwidth}{1{a}.}|}{%
\item lorem ipsum
\item lorem ipsum
\item lorem ipsum}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Exceptions: & \multicolumn{3}{l|}{ }\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Notes and issues: & \multicolumn{3}{l|}{ }\\
% --------------------------------------------------------------------------------------------------------------
\hline
\end{longtable}
\end{document}
I think you had too many columns and too much markup generally, I think I 'd do this unless you really need the lists to break over a page.
\documentclass{article}
\usepackage{longtable,array}
\setlength\extrarowheight{3pt}
\begin{document}
\begin{longtable}{| p{3.5cm} | p{9cm} |}
\caption{Use case detail}\label{chap3:tab1}\\[12pt]
\endfirsthead
\multicolumn{2}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}}\\[12pt]
\hline
\endhead
\hline
\multicolumn{2}{r}{\tablename\ \thetable\ -- \textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
\hline
% --------------------------------------------------------------------------------------------------------------
Use Case ID: & 1\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Use Case Name: & FIXME - Section Name\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Created by:&\hspace{2cm}\vrule\ Date created:\hspace{2cm}\vrule\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Actors &
Doctor\newline
Patient\newline
Patients' Database\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Description: &
The doctor logs into the system, creates/updates the patient medical record, prints the informed consent form and collects it after the patient has signed it.\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Preconditions: &\mbox{}\par\vspace{-\baselineskip}
\begin{enumerate}
\item The doctor is logged into the web software.
\item There is no record for the patient on the patients' database.
\end{enumerate}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Postconditions: & \\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Trigger: & The doctor logs in the system and presses the \textit{Login} button\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Normal flow: &\mbox{}\par\vspace{-\baselineskip}
\begin{enumerate}
\item the doctor clicks on the \textit{Patients} icon;
\item the doctor clicks on the \textit{Add} button;
\item the doctor prints the consent form by clicking on the dedicated button;
\item the doctor fills in the patient's details;
\item the doctor collects the signed patient's consent form and ticks the dedicated check box;
\end{enumerate}\\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Alternative flows: & \\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Exceptions: & \\
% --------------------------------------------------------------------------------------------------------------
\hline
% --------------------------------------------------------------------------------------------------------------
Notes and issues: &\\
% --------------------------------------------------------------------------------------------------------------
\hline
\end{longtable}
\end{document}