使用多行时,条目与其他列重叠
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{table}
\begin{tabular}{|L{3cm} | L{3cm} | L{3cm} | L{3cm} |} \hline
Phases & Input & Process & Output \\ \hline
Phase 1 Acquisition of DNS query logs & DNS queries from MSU-IIT campus network & Name resolution via an existing DNS server & DNS query logs \\ \hline
\multirow{2}{*}{Phase 2 Development of the domain name recommendation engine} & DNS query logs & Co-occurrence transformation & Co-occurrence matrix \\ \cline{2-4}
& Co-occurrence matrix & Self-organizing feature map training & Transaction clusters \\ \cline{2-4} \hline
\end{tabular}
\end{table}
有什么帮助吗?
答案1
如果与 一起使用,则 的文本参数\multirow
将被放入 中,以指定宽度。和朋友可用于获取多行文本条目:\hbox
*
\parbox
\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{ragged2e}
\newcolumntype{L}[1]{%
>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}%
}
\begin{document}
\begin{table}
\begin{tabular}{|L{3cm} | L{3cm} | L{3cm} | L{3cm} |} \hline
Phases & Input & Process & Output \\ \hline
Phase 1 Acquisition of DNS query logs & DNS queries from MSU-IIT campus
network & Name resolution via an existing DNS server & DNS query logs \\
\hline
\multirow{2}{*}{%
\parbox{3cm}{\RaggedRight
Phase 2 Development of the domain name recommendation engine}%
} & DNS query logs & Co-occurrence transformation & Co-occurrence
matrix \\ \cline{2-4}
& Co-occurrence matrix & Self-organizing feature map training &
Transaction clusters \\ \hline
\end{tabular}
\end{table}
\end{document}
如果没有连字符,条目就会太长一行,因此示例中使用\RaggedRight
而不是\raggedright
。
在 的参数中使用3cm
代替更简单。然后文本将自动设置为多行条目。*
\multirow
<fixup>
参数移动条目,因此五行适合空间并且不再需要连字符:
\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\newcolumntype{L}[1]{%
>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}%
}
\begin{document}
\begin{table}
\begin{tabular}{|L{3cm} | L{3cm} | L{3cm} | L{3cm} |} \hline
Phases & Input & Process & Output \\ \hline
Phase 1 Acquisition of DNS query logs & DNS queries from MSU-IIT campus
network & Name resolution via an existing DNS server & DNS query logs \\
\hline
\multirow{2}{3cm}[1.25ex]{%
\raggedright
Phase 2 Development of the domain name recommendation engine%
}
& DNS query logs & Co-occurrence transformation & Co-occurrence
matrix \\ \cline{2-4}
& Co-occurrence matrix & Self-organizing feature map training &
Transaction clusters \\ \hline
\end{tabular}
\end{table}
\end{document}
带包装的变体booktabs
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\newcolumntype{L}[1]{%
>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}%
}
\begin{document}
\begin{table}
\begin{tabular}{L{3cm} L{3cm} L{3cm} L{3cm}}
\toprule
Phases & Input & Process & Output \\
\midrule
Phase 1 Acquisition of DNS query logs & DNS queries from MSU-IIT campus
network & Name resolution via an existing DNS server & DNS query logs \\
\midrule
\smash{\begin{tabular}[t]{@{}L{3cm}@{}}
Phase 2 Development of the domain name recommendation engine%
\end{tabular}}
& DNS query logs & Co-occurrence transformation & Co-occurrence
matrix \\
\cmidrule{2-4}
& Co-occurrence matrix & Self-organizing feature map training &
Transaction clusters \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
我宁愿使用tabularx
环境,并将内容放在列大小的范围内\multirow
()。我添加了包以在行中添加一些垂直填充,并添加了包(来自包)以具有可变宽度的线:\parbox
X
\hsize
cellspace
boldline
shipunov
\documentclass{article}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{array, booktabs, tabularx, caption}
\renewcommand\tabularxcolumn[1]{>{\RaggedRight\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage{ragged2e}
\usepackage{multirow}
\usepackage{boldline}
\usepackage{cellspace}
\renewcommand\cellspacetoplimit{3pt}
\renewcommand\cellspacebottomlimit{3pt}
\addparagraphcolumntypes{X}
\begin{document}
\mbox{}\\
\begin{table}[h]
\centering\setlength\tabcolsep{4pt}
\begin{tabularx}{\linewidth-1.75em}{V{2}*{3}{S{X}|}S{X}V{2}}
\hlineB{2.5}
\textbf{Phases} & \textbf{Input} & \textbf{Process} & \textbf{Output} \\
\hlineB{1.6}
\textbf{Phase 1}: Acquisition of DNS query logs & DNS queries from MSU-IIT campus network & Name resolution via an existing DNS server & DNS query logs \\
\hline
\multirow{2}{*}[0.75ex]{\parbox{\hsize}{\RaggedRight\textbf{Phase 2}: Development of the domain name recommendation engine}} & DNS query logs & Co-occurrence transformation & Co-occurrence matrix \\
\cline{2-4}
& Co-occurrence matrix & Self-organizing feature map training & Transaction clusters \\
\hlineB{2.5}
\end{tabularx}
\end{table}
\end{document}