我正在寻找一种方法来删除两个单元格之间的垂直线,保持后续行的垂直线完好无损。即在下面显示的示例中,7.5% 之前的线和 17.5% 之后的线没有删除定义框的垂直线。
这是我从我使用的代码中得到的结果,如下所述:
我想保留表格格式,以便我可以通过填写相应的单元格来突出显示/着色特定条件。对我可以尝试什么有什么建议吗?
\documentclass[a4paper]{book}
\usepackage{tikz}
\usepackage{float} % H command
\usepackage{booktabs} % for cmidrule
\usepackage{nicematrix}
\begin{document}
\begin{table}[H]
\centering
\begin{NiceTabular}{cc|rcccc|c}
& \Block{1-*}{+ 10 $\%$ MPD} \\
& \Block{1-*}{PEG3350 + PEG1000} \\
& & \small 7.5 $\%$ & \small 10 $\%$ & \small 12.5 $\%$ & \small 15 $\%$ & \small 17.5 $\%$ & \\
\cmidrule{3-7}
\Block{3-1}{\rotate NPS salts [mM]} & \small 10 & & & & & & \Block{3-1}{\rotate \small 100 mM bicine/Tris \\ Hcl pH 8.5}\\
& \small 30 & & & & \\
& \small 50 & & & & \\
\cmidrule{3-7}
\end{NiceTabular}
\end{table}
\end{document}
感谢您关于使用 tabularray 的建议,通过这个包我得到了我正在寻找的结果。
如果其他人正在寻找类似的问题,请查找下面的新代码。
\documentclass[a4paper]{book}
\usepackage{tikz} % this is for graphics
\usepackage{float} %this is for H commands
\usepackage{booktabs} % for PCR command / cmidrule
\usepackage{tabularray}
\begin{document}
\begin{table}[H]
\centering
\begin{tblr}{
hline{4,Y} = {3-7}{0.75pt},
vline{3,8} = {4-6}{0.75pt},
}
& &\SetCell[c=5]{c} + 10 $\%$ MPD \\
& &\SetCell[c=5]{c} PEG3350 + PEG1000 \\
\SetCell[r=5]{c} \rotatebox{90}{\small NPS salts [mM]} & & \small 7.5 $\%$ & \small 10 $\%$ & \small 12.5 $\%$ & \small 15 $\%$ & \small 17.5 $\%$ & \SetCell[r=5]{c, 0.2cm}\rotatebox{90} {\small 100 mM bicine/Tris} & \SetCell[r=5]{c, 0.1cm}\rotatebox{90} {\small Hcl pH 8.5} \\
& 10 & & & & & & \\
& 30 & & & & & & \\
& 50 & & & & & & \\
& & & & & & & &
\end{tblr}
\end{table}
\end{document}
使用
nicematrix
,在表格中绘制矩形的最简单方法是使用命令\Block
和键draw
(绘制块的框架)。
\documentclass[a4paper]{book}
\usepackage{float} % H command
\usepackage{nicematrix}
\begin{document}
\begin{table}[H]
\centering
\begin{NiceTabular}{ccrccccc}
& \Block{1-*}{+ 10 $\%$ MPD} \\
& \Block{1-*}{PEG3350 + PEG1000} \\
& & \small 7.5 $\%$ & \small 10 $\%$ & \small 12.5 $\%$ & \small 15 $\%$ & \small 17.5 $\%$ & \\
\Block{3-1}{\rotate NPS salts [mM]} & \small 10 & \Block[draw]{3-5}{}
& & & & & \Block{3-1}{\rotate \small 100 mM bicine/Tris \\ Hcl pH 8.5}\\
& \small 30 & & & & \\
& \small 50 & & & & \\
\end{NiceTabular}
\end{table}
\end{document}
如果您想要圆角,请使用键
rounded-corners
:
\documentclass[a4paper]{book}
\usepackage{float} % H command
\usepackage{nicematrix}
\begin{document}
\begin{table}[H]
\centering
\begin{NiceTabular}{ccrccccc}
& \Block{1-*}{+ 10 $\%$ MPD} \\
& \Block{1-*}{PEG3350 + PEG1000} \\
& & \small 7.5 $\%$ & \small 10 $\%$ & \small 12.5 $\%$ & \small 15 $\%$ & \small 17.5 $\%$ & \\
\Block{3-1}{\rotate NPS salts [mM]} & \small 10 & \Block[draw,rounded-corners]{3-5}{}
& & & & & \Block{3-1}{\rotate \small 100 mM bicine/Tris \\ Hcl pH 8.5}\\
& \small 30 & & & & \\
& \small 50 & & & & \\
\end{NiceTabular}
\end{table}
\end{document}
如果你想用背景颜色填充它,请使用键
fill
:
\documentclass[a4paper]{book}
\usepackage{float} % H command
\usepackage{nicematrix}
\begin{document}
\begin{table}[H]
\centering
\begin{NiceTabular}{ccrccccc}
& \Block{1-*}{+ 10 $\%$ MPD} \\
& \Block{1-*}{PEG3350 + PEG1000} \\
& & \small 7.5 $\%$ & \small 10 $\%$ & \small 12.5 $\%$ & \small 15 $\%$ & \small 17.5 $\%$ & \\
\Block{3-1}{\rotate NPS salts [mM]} & \small 10 & \Block[draw,rounded-corners,fill=red!15]{3-5}{}
& & & & & \Block{3-1}{\rotate \small 100 mM bicine/Tris \\ Hcl pH 8.5}\\
& \small 30 & & & & \\
& \small 50 & & & & \\
\end{NiceTabular}
\end{table}
\end{document}
如果您喜欢渐变颜色,也是可以的(感谢 Tikz)。
\documentclass[a4paper]{book}
\usepackage{float} % H command
\usepackage{nicematrix,tikz}
\begin{document}
\begin{table}[H]
\centering
\begin{NiceTabular}{ccrccccc}
& \Block{1-*}{+ 10 $\%$ MPD} \\
& \Block{1-*}{PEG3350 + PEG1000} \\
& & \small 7.5 $\%$ & \small 10 $\%$ & \small 12.5 $\%$ & \small 15 $\%$ & \small 17.5 $\%$ & \\
\Block{3-1}{\rotate NPS salts [mM]} & \small 10 &
\Block[draw,rounded-corners,tikz={left color=red!15}]{3-5}{}
& & & & & \Block{3-1}{\rotate \small 100 mM bicine/Tris \\ Hcl pH 8.5}\\
& \small 30 & & & & \\
& \small 50 & & & & \\
\end{NiceTabular}
\end{table}
\end{document}
由于
nicematrix
在行、单元格和列下创建 PGF/Tikz,因此始终可以绘制和填充您想要的内容...