![表格在顶部添加一个长列,并且 \multicolumn 已过时;请改用 \SetCell](https://linux22.com/image/469627/%E8%A1%A8%E6%A0%BC%E5%9C%A8%E9%A1%B6%E9%83%A8%E6%B7%BB%E5%8A%A0%E4%B8%80%E4%B8%AA%E9%95%BF%E5%88%97%EF%BC%8C%E5%B9%B6%E4%B8%94%20%5Cmulticolumn%20%E5%B7%B2%E8%BF%87%E6%97%B6%EF%BC%9B%E8%AF%B7%E6%94%B9%E7%94%A8%20%5CSetCell.png)
我正在尝试在工作中添加一个表格。我在上面画了一个带红色边框的矩形,以显示我想要放置长列的位置。然后,我得到了这些错误,如果我解决它们,表格渲染就会变得一团糟。
我的代码:
{\renewcommand{\arraystretch}{1.6}%
\small
\begin{table}[H]
\small
\centering
\caption{}\label{tab:blockchains}
\scalebox{0.97}{
\begin{tblr}{colspec={l *{5}{X[c,m]}},
rows = {font=\linespread{1}\selectfont},
row{1} = {},
hline{1} = {2-7}{solid},
hline{2-7} = {solid},
vline{1} = {2-7}{solid},
vline{2-7} = {solid}
}
\SetCell[c=1]{c,white}
\multicolumn{1}{l|}{} & Platform & Memory & Specification & Price \\
\multicolumn{1}{|l|}{} & Windows & 16GB & Whatever & 10K \\
\multicolumn{1}{|l|}{} & Windows, 32GB & Professional & 22K \\
\multicolumn{1}{|l|}{} & Linux, 64GB & Hacker IBM & 32K \\
\end{tblr}}
\end{table}}
答案1
这些冒犯\multicolumn
看起来是没有必要的,只需将其删除:
\documentclass{article}
\usepackage{tabularray}
\usepackage{xcolor}
\begin{document}
\begin{tblr}{colspec={l *{4}{X[c,m]}},
hline{1-2} = {2-Z}{solid,red},
hline{3-Z} = {solid},
vline{1} = {3-Z}{solid},
vline{2-Z} = {solid},
vline{2-Z} = {1}{solid,red},
}
& \SetCell[c=4]{}\\
& Platform & Memory & Specification & Price \\
& Windows & 16GB & Whatever & 10K \\
& Windows, 32GB & Professional & 22K \\
& Linux, 64GB & Hacker IBM & 32K \\
\end{tblr}
\end{document}