如何在多列中添加白色垂直说明符,如以下行所示?是否也可以使用更宽的垂直说明符?
\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[h!]
\centering
\caption{Caption}
%\label{table:Label}
\renewcommand{\arraystretch}{1.2}% for the vertical padding
%\begin{tabular}{ c| c }
\begin{tabular}{c!{\color{white}\vrule}c}
%\rowcolor{cyan!30}
%\multicolumn{1}{c}{Σχέση} & \multicolumn{1}{c}{Τύπος} \\
%\multicolumn{1}{l!{\color{white}\vrule}l}{Σχέση} & \multicolumn{1}{c}{Τύπος} \\
& \\[-1.3em]
\multicolumn{1}{c}{{\cellcolor{cyan!30}}Title 1} & \multicolumn{1}{c}{{\cellcolor{cyan!30}}Title 2} \\
& \\[-1.3em]
\rule{0pt}{1.5em}\cellcolor{black!10} A & \cellcolor{red!10} B \\[.5em]
& \\[-1.3em]
\rule{0pt}{1.5em}\cellcolor{black!10} B & \cellcolor{red!10} D \\[.5em]
\end{tabular}
\end{table}
\end{document}
答案1
我不确定是否理解了您的需求,但我认为您可以使用tabularray
:
\documentclass{article}
\usepackage{xcolor}
\usepackage{tabularray}
\begin{document}
\begin{table}[h!]
\centering
\caption{Caption}\label{table:Label}
\begin{tblr}{
cells={c,m},stretch=0,
vlines={white}, hlines={white},
column{1}={black!10},
column{2}={red!10},
row{1}={cyan!30},
rows={ht=.8cm},
}
Title 1 & Title 2 \\
A & B \\
B & D \\
\end{tblr}
\end{table}
\end{document}
答案2
如果您想要白色规则,请告诉 LaTeX。
您可以使用\mystrut
选择单元格的垂直拉伸量。这里\mystrut
,但您可以尝试\mystrut[1.2]
或任何其他方式。
\documentclass{article}
\usepackage{fontspec}
\usepackage[table]{xcolor}
\setmainfont{Old Standard} % supports Greek
\newcommand{\mystrut}[1][1.5]{%
\vrule width 0pt height 1.5\ht\strutbox depth 1.5\dp\strutbox\relax
}
\begin{document}
\begin{table}[htp!]
\centering
\arrayrulecolor{white}
\setlength{\arrayrulewidth}{1pt}
\begin{tabular}{>{\mystrut}c|c}
\rowcolor{cyan!30}
Σχέση & Τύπος \\
\cellcolor{cyan!30}Title 1 & \cellcolor{cyan!30}Title 2 \\
\hline
\cellcolor{black!10} A & \cellcolor{red!10} B \\
\cellcolor{black!10} B & \cellcolor{red!10} D \\
\end{tabular}
\caption{Caption}\label{table:Label}
\end{table}
\end{document}