在其他列中添加更多行以使另一列中的行不匹配

在其他列中添加更多行以使另一列中的行不匹配

我一直在尝试使用 latex 来实现这一点。我为此使用了 tabularray。

这是我在 Microsoft Word 中的操作方式: 用词

以下是我目前在 Latex 中得到的内容:

乳胶

\PassOptionsToPackage{table}{xcolor}
\documentclass[11pt]{article} 
\usepackage{nccmath}
\usepackage[table]{xcolor} 
\usepackage{tabularray}

\begin{document}

\centerline{\textbf{Table 1: Position \& Time Data}}

\centering
\begin{tblr}{|c|c|c|c|}
\hline
t (s) & x (cm) & $\Delta$x (cm) & V$_{\text{avg}}$ (cm/s) \\ \hline
1-1 & 1-2 & \SetCell[r=2]{c, black!50} & \SetCell[r=2]{c, black!50} \\ \hline
2-1 & 2-2 &  &  \\ \hline
3-1 & 3-2 & 1.5-3 & 1.5-4 \\ \hline
4-1 & 4-2 & 2.5-3 & 2.5-4 \\ \hline
5-1 & 5-2 & \SetCell[r=2]{c, black!50} & \SetCell[r=2]{c, black!50} \\ \hline
6-1 & 6-2 & 6-3 & 6-4 \\ \hline
\end{tblr}
\end{document}

答案1

我想这就是你想要的。我不得不添加第 5 列来对齐行,尽管这是 tblr 特有的问题。

\documentclass[11pt]{article} 
\usepackage{nccmath}
\usepackage[table]{xcolor} 
\usepackage{tabularray}

\begin{document}

\centerline{\textbf{Table 1: Position \& Time Data}}

\centering
\begin{tblr}{|c|c|c|c|l@{}}
\cline{1-4}
t (s) & x (cm) & $\Delta$x (cm) & V$_{\text{avg}}$ (cm/s) & \strut\\ \cline{1-4}
\SetCell[r=2]{c} 1-1 & \SetCell[r=2]{c} 1-2 & \SetCell{black!50} & \SetCell{black!50} & \strut \\ \cline{3-4}
 & & \SetCell[r=2]{c} 1.5-3 & \SetCell[r=2]{c} 1.5-4 & \strut\\ \cline{1-2}
\SetCell[r=2]{c} 2-1 & \SetCell[r=2]{c} 2-2 & & & \strut \\ \cline{3-4}
 & & \SetCell[r=2]{c} 2.5-3 & \SetCell[r=2]{c} 2.5-4 & \strut\\ \cline{1-2}
\SetCell[r=2]{c} 5-1 & \SetCell[r=2]{c} 5-2 & & & \strut\\ \cline{3-4}
& & \SetCell{black!50} & \SetCell{black!50} & \strut \\ \cline{1-4}
\end{tblr}\hspace{-\tabcolsep}

\end{document}

演示

相关内容