我无法生成正确的 Latex 表。我目前正在使用以下代码:
\begin{tabular}{|c|c|c|c|}
\hline
Application and Activity Name & Original \textbackslash Faulted & Activity Classified as: & \multicolumn{1}{c|}{Functional Bugs Discovered} \\ \hline
\multirow{6}{*}{\begin{tabular}[c]{@{}c@{}}K-9Mail:\\ MessageList\end{tabular}} & Original & \multirow{5}{*}{Mail Activity} & \begin{tabular}[c]{@{}l@{}}1 bug has been found:\\ \# Sending an email with invalid\\ recipient address - Failed\end{tabular} \\ \cline{2-2} \cline{4-4}
& \multirow{5}{*}{Faulted} & & \multirow{5}{*}{\begin{tabular}[c]{@{}l@{}}4 bugs have been found:\\ \# Opening an email from the inbox\\ mails list - Failed\\ \# Sending an email without\\ recipient address - Failed\\ \# Sending an email with invalid\\ recipient address - Failed\\ \# Sending and receiving a valid\\ mail - Failed\end{tabular}} \\
& & & \\
& & & \\
& & & \\
& & & \\ \\ \\ \\ \\ \hline
\multirow{6}{*}{\begin{tabular}[c]{@{}c@{}}K-9Mail:\\ setup.AccountSetupBasics\end{tabular}} & Original & \multirow{6}{*}{Login Activity} & No bugs have been found \\ \cline{2-2} \cline{4-4}
& \multirow{5}{*}{Faulted} & & \multirow{5}{*}{\begin{tabular}[c]{@{}l@{}}3 bugs have been found:\\ \# Login without username and\\ password - Failed\\ \# Login with wrong username\\ and password - Failed\\ \# Login with valid username\\ and password - Failed\end{tabular}} \\
& & & \\
& & & \\
& & & \\
& & & \\ \\ \\ \hline
\multirow{6}{*}{\begin{tabular}[c]{@{}c@{}}CrimeTalk:\\ MainActivity\end{tabular}} & Original & \multirow{6}{*}{Portal Activity} & No bugs have been found \\ \cline{2-2} \cline{4-4}
& \multirow{5}{*}{Faulted} & & \multirow{5}{*}{\begin{tabular}[c]{@{}l@{}}3 bugs have been found:\\ \# Browsing through the portal's\\ sections by swiping it left \\ and right - Failed\\ \# Switching between the portal's\\ tabs - Failed\\ \# Opening an article - Failed\end{tabular}} \\
& & & \\
& & & \\
& & & \\
& & & \\ \\ \\ \hline
\end{tabular}
可以看出,这个表格的某些地方缺少边框。有人可以修改我的代码来解决这个问题吗?我花了好几个小时才解决这个问题,但没有任何结果。
任何帮助都感激不尽。
提前感谢你,奥雷尔。
答案1
这是一个解决方案,它针对第四列中的项目使用专用的、紧凑的类似 itemize 的环境进行操作。
\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters suitably
\usepackage{multirow}
\usepackage{tabularx,ragged2e}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}
\setlength\extrarowheight{2pt}
\usepackage{enumitem}
%% Setup a compact ittemize-like env.
\newlist{mylist}{itemize}{1}
\setlist[mylist]{label=\#,
nosep, wide, leftmargin=*,
before=\vspace{-0.57\baselineskip},
after =\vspace{-0.85\baselineskip}}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{|c|c|c|Y|}
\hline
Application and Activity Name & Original\slash Faulted
& Activity Classified as:
& Functional Bugs Discovered \\
\hline
\multirow{6}{*}{%
\begin{tabular}[c]{@{}c@{}}
K-9Mail:\\
MessageList
\end{tabular}}
& Original
& \multirow{5}{*}{Mail Activity}
& \begin{tabular}[c]{@{}Y@{}}
1 bug was found:\\
\begin{mylist}
\item Sending an email with invalid recipient address~-- Failed
\end{mylist}
\end{tabular} \\
\cline{2-2} \cline{4-4}
& \multirow{5}{*}{Faulted}
&
& \begin{tabular}[c]{@{}Y@{}}
4 bugs were found:\\
\begin{mylist}
\item Opening an email from the inbox mails list~-- Failed
\item Sending an email without recipient address~-- Failed
\item Sending an email with invalid recipient address~-- Failed
\item Sending and receiving a valid mail~-- Failed
\end{mylist}
\end{tabular} \\
\hline
\multirow{6}{*}{%
\begin{tabular}[c]{@{}c@{}}
K-9Mail:\\
setup.AccountSetupBasics
\end{tabular}}
& Original
& \multirow{6}{*}{Login Activity}
& No bugs were found \\
\cline{2-2} \cline{4-4}
& \multirow{5}{*}{Faulted}
&
& \begin{tabular}[c]{@{}Y@{}}
3 bugs were found:\\
\begin{mylist}
\item Login without username and password~-- Failed
\item Login with wrong username and password~-- Failed
\item Login with valid username and password~-- Failed
\end{mylist}
\end{tabular} \\
\hline
\multirow{6}{*}{\begin{tabular}[c]{@{}c@{}}
CrimeTalk:\\
MainActivity
\end{tabular}}
& Original
& \multirow{6}{*}{Portal Activity}
& No bugs were found \\
\cline{2-2} \cline{4-4}
& \multirow{5}{*}{Faulted}
&
& \begin{tabular}[c]{@{}Y@{}}
3 bugs were found:\\
\begin{mylist}
\item Browsing through the portal's sections by swiping it left and right~-- Failed
\item Switching between the portal's tabs~-- Failed
\item Opening an article~-- Failed
\end{mylist}
\end{tabular} \\
\hline
\end{tabularx}
\end{document}
答案2
缺失的行似乎是由于您\multirow
结合使用了所有空行而导致的。表格前三分之一的更正代码如下:
\documentclass{report}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|c|c|}
\hline
Application and Activity Name & Original \textbackslash Faulted & Activity Classified as: & \multicolumn{1}{c|}{Functional Bugs Discovered} \\ \hline
\multirow{10}{*}{\begin{tabular}[c]{@{}c@{}}K-9Mail:\\ MessageList\end{tabular} } & Original & \multirow{10}{*}{Mail Activity} & \begin{tabular}[c]{@{}l@{}}1 bug has been found:\\ \# Sending an email with invalid\\ recipient address - Failed\end{tabular} \\ \cline{2-2} \cline{4-4}
& \multirow{2}{*}{Faulted} & & \begin{tabular}[c]{@{}l@{}}4 bugs have been found:\\ \# Opening an email from the inbox\\ mails list - Failed\\ \# Sending an email without\\ recipient address - Failed\\ \# Sending an email with invalid\\ recipient address - Failed\\ \# Sending and receiving a valid\\ mail - Failed\end{tabular} \\
\hline
\end{tabular}
\end{document}
尽管如此,表格仍然不适合纵向页面,而且由于所有垂直和水平线,看起来有些拥挤。重新设计后可能如下所示:
\documentclass{report}
\usepackage{array}
\usepackage{tabularx}
\usepackage{booktabs}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{L{2.5cm}L{2cm}L{2cm}>{\raggedright\arraybackslash}X}
\toprule
Application and Activity Name & Activity Classified as: & Original \textbackslash Faulted & Functional Bugs Discovered \\
\midrule
K-9Mail: \newline MessageList & Mail \newline Activity &Original & 1 bug has been found:\newline \# Sending an email with invalid recipient address - Failed \\
\cmidrule{3-4}
& & Faulted & 4 bugs have been found:\newline \# Opening an email from the inbox mails list - Failed\newline \# Sending an email without recipient address - Failed\newline \# Sending an email with invalid recipient address - Failed\newline \# Sending and receiving a valid mail - Failed \\
\bottomrule
\end{tabularx}
\end{document}
答案3
另一种解决方案,也基于tabularx
和enumitem
,没有嵌套tabular
,而是使用makecell
,因为它允许在标准单元格中换行:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{float}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{tabularx, multirow, makecell}
\usepackage{enumitem}
\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{label=\#, noitemsep, topsep=2pt, wide=0pt, after=\vspace*{\dimexpr\topsep + \partopsep-\baselineskip}}
\begin{document}
\noindent\setlength{\extrarowheight}{3pt}
\begin{tabularx}{\linewidth}{|c|c|c| >{\arraybackslash}X|}
\hline
\makecell{Application and\\ Activity Name} & \makecell{Original\\ \textbackslash Faulted} & \makecell{Activity\\ Classified as:} & \multicolumn{1}{c|}{Functional Bugs Discovered} \\
\hline
\multirowcell{11}{K-9Mail:\\ MessageList} & Original & \multirowcell{11}{Mail Activity} & 1 bug has been found:\begin{tabitemize}\item Sending an email with invalid recipient address – Failed \end{tabitemize}\\
\cline{2-2} \cline{4-4}
& \multirowcell{5}{Faulted} &
& 4 bugs have been found:\begin{tabitemize}
\item Opening an email from the inbox mails list – Failed
\item Sending an email without recipient address – Failed
\item Sending an email with invalid recipient address – Failed
\item Sending and receiving a valid mail – Failed
\end{tabitemize}
\\ \hline
\multirowcell{7.5}{K-9Mail:\\ setup.AccountSetupBasics} & Original & \multirowcell{7.5}{Login Activity} & No bugs have been found \\ \cline{2-2} \cline{4-4}
& \multirowcell{5.5}{Faulted} & & 3 bugs have been found: \begin{tabitemize}
\item Login without username and password – Failed
\item Login with wrong username and password – Failed
\item Login with valid username and password – Failed
\end{tabitemize}
\\ \hline
\multirowcell{7.5}{CrimeTalk:\\ MainActivity} & Original & \multirowcell{7.5}{Portal Activity} & No bugs have been found \\
\cline{2-2} \cline{4-4}
& \multirowcell{5.5}{Faulted} & & 3 bugs have been found: \begin{tabitemize}
\item Browsing through the portal's sections by swiping it left and right – Failed
\item Switching between the portal's tabs – Failed
\item Opening an article – Failed
\end{tabitemize}
\\ \hline
\end{tabularx}
\end{document}