
我正在嘗試製作一個多列表,其中第一列與其餘列一樣有 n-1 行。我正在尋找的視覺草圖是:
Date | Value 1 | Value 2 | Value 3
| X | X | X
DD/MM/YYYY -----------------------------
| X | X | X
DD/MM/YYYY -----------------------------
| X | X | X
DD/MM/YYYY -----------------------------
| X | X | X
使用這個multicolumn
包,我已經接近了
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{cccc}
\hline
Date & Value 1 & Value 2 & Value 3 \\
\multirow{2}{*}{DD/MM/YYYY}
&X&X&X\\
\cline{2-4}
&Y&Y&Y\\
\multirow{2}{*}{DD/MM/YYYY}
&Y&Y&Y\\
\cline{2-4}
&Y&Y&Y\\
\multirow{2}{*}{DD/MM/YYYY}
&Y&Y&Y\\
\cline{2-4}
&X&X&X\\
\hline
\end{tabular}
\end{table}
\end{document}
這是我所能達到的最接近的結果,但這種方法會為每次使用\multirow
.實際上,乳膠範例中表示為 Y 的所有值都是多餘的,只需要出現一次。
我希望這一點很清楚。先致謝
答案1
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{cccc}
\hline
Date & Value 1 & Value 2 & Value 3 \\[4pt]
\multirow{3}{*}{DD/MM/YYYY} &X&X&X\\ [4pt] \cline{2-4}
&&&\\
\multirow{3}{*}{DD/MM/YYYY} &Y&Y&Y\\ [4pt] \cline{2-4}
&&&\\
\multirow{3}{*}{DD/MM/YYYY} &Y&Y&Y\\ [4pt] \cline{2-4} &&&\\
&X&X&X\\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
透過強制垂直重疊\multirow
單元格,就像您在問題中所做的那樣。因此,您只能在單元格中添加一些垂直空間:
\documentclass{article}
\usepackage{makecell, multirow} % <---
\begin{document}
\begin{table}[ht]
\setcellgapes{5pt} % <---
\makegapedcells % <---
\centering
\begin{tabular}{cccc}
\hline
Date & Value 1 & Value 2 & Value 3 \\[4pt]
\multirow{2}{*}[-2pt]{DD/MM/YYYY} & X & X & X \\ \cline{2-4}
\multirow{2}{*}[-2pt]{DD/MM/YYYY} & Y & Y & Y \\ \cline{2-4}
\multirow{2}{*}[-2pt]{DD/MM/YYYY} & Z & Z & Z \\ \cline{2-4}
& X & X & X \\
\hline
\end{tabular}
\end{table}
\end{document}
答案3
與.{NiceTabular}
nicematrix
\documentclass{article}
\usepackage{nicematrix,tikz,booktabs}
\begin{document}
\begin{NiceTabular}{cccc}
\toprule
Date & Value 1 & Value 2 & Value 3 \\[1mm]
& X & X & X \\
DD/MM/YYYY & \Cdots[line-style=solid] \\
& Y & Y & Y \\
DD/MM/YYYY & \Cdots[line-style=solid] \\
& Z & Z & Z \\
DD/MM/YYYY & \Cdots[line-style=solid] \\
& X & X & X \\
\bottomrule
\end{NiceTabular}
\end{document}