我正在使用该multirow
包排版表格,其中两行应该合并为一行。我仔细查看了我的代码并将其与工作示例进行比较,但它无法工作。一条丑陋的水平线穿过应该合并的行。
\documentclass{article}
\usepackage{array, float, multirow}
\begin{document}
\begin{table}[H]
\centering
\caption{LLLL}
\label{tab:location-xiagu}
\begin{tabular}{|c|>{\centering}m{0.1\textwidth}|m{0.5\textwidth}|}
\hline
\multirow{2}{*}{A} & B & C\tabularnewline
\hline
& A & C \tabularnewline
\hline
\multirow{2}{*}{X} & W & E \tabularnewline
\hline
& O & E \tabularnewline
\hline
\multirow{2}{*}{S} & M & N \tabularnewline
\hline
& P & W \tabularnewline
\hline
\end{tabular}
\end{table}
\end{document}
但我不想让A, X, S
字母之间出现交叉线。提前致谢!
答案1
\hline
将绘制一条完整的线,您需要使用\cline{2-3}
以下命令:
\documentclass{article}
\usepackage{array, float, multirow}
\begin{document}
\begin{table}[H]
\centering
\caption{LLLL}
\label{tab:location-xiagu}
\begin{tabular}{|c|>{\centering}m{0.1\textwidth}|m{0.5\textwidth}|}
\hline
\multirow{2}{*}{A} & B & C\tabularnewline
\cline{2-3}
& A & C \tabularnewline
\hline
\multirow{2}{*}{X} & W & E \tabularnewline
\cline{2-3}
& O & E \tabularnewline
\hline
\multirow{2}{*}{S} & M & N \tabularnewline
\cline{2-3}
& P & W \tabularnewline
\hline
\end{tabular}
\end{table}
\end{document}
或者,您可以使用 booktabs 并删除垂直线,对我来说,这会产生更令人满意的效果:
\documentclass{article}
\usepackage{array, float, multirow}
\usepackage{booktabs,caption}
\begin{document}
\begin{table}[H]
\centering
\caption{LLLL}
\label{tab:location-xiagu}
\begin{tabular}{c >{\centering}m{0.1\textwidth} m{0.5\textwidth} }
\toprule
\multirow{2}{*}{A} & B & C\tabularnewline
& A & C \tabularnewline
\midrule
\multirow{2}{*}{X} & W & E \tabularnewline
& O & E \tabularnewline
\midrule
\multirow{2}{*}{S} & M & N \tabularnewline
& P & W \tabularnewline
\bottomrule
\end{tabular}
\end{table}
\end{document}
由于其他人有注释,因此包caption
将为表格上方的标题提供适当的间距。
答案2
一些改进:我向单元格添加了一些填充,并使用可变宽度的垂直和水平规则boldline
:
\documentclass{article}
\usepackage{array, float, multirow, caption, boldline}
\begin{document}
\begin{table}[H]
\centering\setlength{\extrarowheight}{2pt}
\caption{LLLL}
\label{tab:location-xiagu}
\begin{tabular}{V{2.5}cV{2.5}>{\centering}m{0.1\textwidth}| >{\arraybackslash}m{0.5\textwidth}V{2.5}}
\hlineB{2.5}
\multirow{2}{*}{A} & B & C \\
\cline{2-3}
& A & C \\
\hlineB{2.5}
\multirow{2}{*}{X} & W & E \\
\cline{2-3}
& O & E \\
\hlineB{2.5}
\multirow{2}{*}{S} & M & N \\
\cline{2-3}
& P & W \\
\hlineB{2.5}
\end{tabular}
\end{table}
\end{document}