答案1
基于tabularx
和的解决方案enumitem
。请注意,这里实际上不需要multirow
。
\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage{array}
\usepackage{enumitem}
\usepackage{tabularx, caption}
\captionsetup{skip=6pt}
\usepackage{ragged2e}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\begin{document}
\begin{table}[!htb]
\sffamily\small
\setlength{\tabcolsep}{4pt}
\setlength{\extrarowheight}{2pt}
\centering
\caption{Some caption} \label{table-test}
\begin{tabularx}{\linewidth}{|p{1.4cm}|p{1.5cm}| >{\compress\RaggedRight}X|*{3}{p{21mm}|}}
\hline
Test case & Action & ~Test procedure & Expected result & Actual result & Remarks\\
\hline
{Login} & User login &
\begin{enumerate}[wide=0pt, leftmargin=*, itemsep=0pt, after=\leavevmode\vspace*{-\dimexpr\topsep+\partopsep}]
\item Provide username and password
\item Validate all fields have been filled
\item Goes to the Main Site
\end{enumerate}
& Successfully
logged in & Successfully logged in & Logged in \\
\cline{2-2} \cline{4-6}
& Missing credentials & & ... & ... & Cannot log in\\[3cm]
\hline
\end{tabularx}
\end{table}
\end{document}
答案2
你是对的,很难说服 LaTeX 创建这样一个没有吸引力的表格,但当然可以做到。;-)
\documentclass[10pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{array,multirow}
\begin{document}
\sffamily\small
\begin{tabular}{|p{1.5cm}|p{1cm}|@{}p{3cm}|*{3}{p{2.5cm}|}}
\hline
Test case & Action & ~Test procedure & Expected result & Actual result & Remarks\\
\hline
\multirow{2}{=}{Login} & User login & \multirow{2}{=}{
\begin{enumerate}
\item Provide username and password
\item Validate all fields have been filled
\item Goes to the Main Site
\end{enumerate}
} & Successfully
logged in & Successfully logged in & logged in \\[3cm]
\cline{2-2} \cline{4-6}
& Missing credentials & & \dots & \dots & Cannot log in\\[3cm]
\hline
\end{tabular}
\end{document}