我想使用嵌套表代替multirow
,我有这个例子
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
%\tabcolsep0pt %this makes the second table
\begin{tabular}{|l|l|} \hline
Test & Test2 \\ \hline
Test 3 & {\begin{tabular}{|l|} \hline
can i remove \\ \hline
the spaceing here \\ \hline
\end{tabular}} \\ \hline
\end{tabular}
\end{document}
这就是输出的样子。我知道这\tabcolsep0pt
可以删除单元格内容和表格线之间的空格。但它会从所有单元格中删除它,这对其他单元格来说看起来很糟糕:
现在我的问题是,我可以\tabcolsep0pt
为包含嵌套表格的单个单元格设置吗?
答案1
\documentclass{article}
\begin{document}
\begin{tabular}{|l|l@{}|}\hline
Test & Test2 \\\hline
Test 3 &
\hfil\hspace{\dimexpr-1\tabcolsep}
\begin{tabular}{l}
can i remove \\\hline
the spaceing here \\
\end{tabular} \\\hline
\end{tabular}
\end{document}
答案2
您可以使用\multicolumn
附加表格来设置单元格的属性。然后@{}
删除空格。
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
%\tabcolsep0pt %this makes the second table
\begin{tabular}{|l|l|} \hline
Test & Test2 \\ \hline
Test 3 & \multicolumn{1}{@{}c@{}|}{%
\begin{tabular}{l}
can i remove \\ \hline
the spaceing here
\end{tabular}} \\ \hline
\end{tabular}
\end{document}
答案3
这是你想要的吗?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hhline}
\begin{document}
\begin{tabular}{|l|l@{}|} \hhline{|--|}
Test & Test2 \\ \hhline{|--|}
Test 3 & \hskip -\tabcolsep{\setlength{\tabcolsep}{0pt}\begin{tabular}{@{}l}
can I remove \\ \cline{1-1}
the spaceing here
\end{tabular}}\\ \hhline{|--|}
\end{tabular}
\end{document}
答案4
另一种使用multirow
嵌套表格的方法:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|l|l|}
\hline
Test & Test2 \\
\hline
\multirow{2}{*}{Test 3} & can i remove \\
\cline{2-2}
& the spaceing here \\
\hline
\end{tabular}
\end{document}