我创建了一些包含几个包的表格,我使用包中的booktabs
命令。但最后我注意到颜色是\rowcolors
xcolor
更宽的同一表的行。由于创建表的方式和所有使用的包都相同,我不知道会发生什么。这是我的 MWE:
\documentclass[fontsize=10pt,paper=letter,headings=big,bibliography=totoc,DIV=8]{scrbook}
\KOMAoptions{headsepline=true,draft=false}
\usepackage{typearea}
\usepackage[usenames,dvipsnames,x11names,table]{xcolor}
\usepackage[single=false,macros=false,xspace=false]{acro}
\usepackage[spanish,mexico]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[sc,osf]{mathpazo}
\usepackage[defaultsans]{opensans}
\usepackage{array,multirow,tabularx,ragged2e,booktabs}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}
\usepackage{rotating}
\usepackage{colortbl}
\usepackage[per-mode=symbol]{siunitx}
\DeclareSIUnit\poise{P}
\DeclareSIUnit\stokes{St}
%\DeclareSIUnit\radian{rad}
\DeclareSIUnit\dyna{dyn}
\begin{document}
\begin{table}
\centering
\rowcolors{2}{}{lightgray!20}
\begin{tabularx}{3.4in}{@{} CS[table-format=4.4] @{}}
\toprule
Propiedades materiales en la media & Valor \\
\midrule
$c_M$ & \SI{3.0}{[\kilo\pascal]} \\
$k_{1_M}$ & \SI{2.3632}{[\kilo\pascal]} \\
$k_{2_M}$ & \num{0.8393} \\
$\beta_M$ & \ang{29.0} \\
$\kappa_M$ & \SI{1000}{[\mega\pascal]}\\
\midrule
Propiedades materiales en la adventicia & Valor \\
\midrule
$c_A$ & \SI{0.3}{[\kilo\pascal]} \\
$k_{1_A}$ & \SI{0.5620}{[\kilo\pascal]} \\
$k_{2_A}$ & \num{0.7112} \\
$\beta_A$ & \ang{62.0} \\
$\kappa_A$ & \SI{1000}{[\mega\pascal]} \\
\bottomrule
\end{tabularx}
\caption[Parámetros materiales de la arteria]{Parámetros materiales de la arteria en sus dos túnicas externas: media y adventicia.}
\label{taula:param}
%\setfloatalignment{t}
\end{table}
\begin{table}
\centering
\rowcolors{2}{}{lightgray!20}
\begin{tabularx}{3.2in}{@{} lYS[table-format=4.4] @{}}
\toprule
\multicolumn{2}{c}{Propiedades materiales} & Valor \\
\midrule
\multirow{2}{*}{\rotatebox{90}{{\footnotesize Sangre}}}
& $\rho_s$ & \SI{1060}{[\kilo\gram\per\metre^3]} \\
& $\mu_{s}$ & \SI{3.8e-6}{[\metre^2\per\second]} \\
\midrule
\rowcolor{white} \multicolumn{3}{c}{Modelo hiperelástico de Mooney-Rivlin}\\
\midrule
\multirow{6}{*}{\rotatebox{90}{{\footnotesize Arteria}}}
& $C_1$ & \SI{0.020}{[\mega\pascal]} \\
& $C_2$ & \SI{0.003}{[\mega\pascal]} \\
& $C_3$ & \SI{0.175}{[\mega\pascal]} \\
& $C_4$ & \SI{0.090}{[\mega\pascal]} \\
& $C_5$ & \SI{0}{[\mega\pascal]} \\
& $C_6$ & \SI{0}{[\mega\pascal]} \\
\midrule
\multicolumn{3}{c}{Modelo hiperelástico de Mooney-Rivlin}\\
\midrule
\multirow{6}{*}{\rotatebox{90}{{\footnotesize Placa}}}
& $C_1$ & \SI{-0.452}{[\mega\pascal]} \\
& $C_2$ & \SI{0.510}{[\mega\pascal]} \\
& $C_3$ & \SI{0.101}{[\mega\pascal]} \\
& $C_4$ & \SI{1.256}{[\mega\pascal]} \\
& $C_5$ & \SI{0}{[\mega\pascal]} \\
& $C_6$ & \SI{0.301}{[\mega\pascal]} \\
\bottomrule
\end{tabularx}
\caption[Parámetros materiales de la sangre, arteria y placa]{Parámetros materiales de la sangre, arteria y placa que los definen como materiales para COMSOL.}
\label{taula:sangue}
\end{table}
\end{document}
两个表都有同样的问题,但第二个表更困难:我尝试添加一个将文本旋转 90º 的列,但我不知道如何使其适合使用相同的配色方案而不覆盖该旋转列的颜色部分...如果可能的话。
答案1
\documentclass[fontsize=10pt,paper=letter,headings=big,bibliography=totoc,DIV=8]{scrbook}
\KOMAoptions{headsepline=true,draft=false}
\usepackage{typearea}
\usepackage[usenames,dvipsnames,x11names,table]{xcolor}
\usepackage[single=false,macros=false,xspace=false]{acro}
\usepackage[spanish,mexico]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[sc,osf]{mathpazo}
\usepackage[defaultsans]{opensans}
\usepackage{array,multirow,tabularx,ragged2e,booktabs}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X}
\usepackage{rotating}
\usepackage{colortbl}
\usepackage[per-mode=symbol]{siunitx}
\DeclareSIUnit\poise{P}
\DeclareSIUnit\stokes{St}
%\DeclareSIUnit\radian{rad}
\DeclareSIUnit\dyna{dyn}
\begin{document}
\begin{table}
\centering
\rowcolors{2}{}{lightgray!20}
\begin{tabularx}{3.4in}{@{\kern\tabcolsep}CS[table-format=4.4]<{\kern\tabcolsep}}
\toprule
Propiedades materiales en la media & Valor \\
\midrule
$c_M$ & \SI{3.0}{[\kilo\pascal]} \\
$k_{1_M}$ & \SI{2.3632}{[\kilo\pascal]} \\
$k_{2_M}$ & \num{0.8393} \\
$\beta_M$ & \ang{29.0} \\
$\kappa_M$ & \SI{1000}{[\mega\pascal]}\\
\midrule
Propiedades materiales en la adventicia & Valor \\
\midrule
$c_A$ & \SI{0.3}{[\kilo\pascal]} \\
$k_{1_A}$ & \SI{0.5620}{[\kilo\pascal]} \\
$k_{2_A}$ & \num{0.7112} \\
$\beta_A$ & \ang{62.0} \\
$\kappa_A$ & \SI{1000}{[\mega\pascal]} \\
\bottomrule
\end{tabularx}
\caption[Parámetros materiales de la arteria]{Parámetros materiales de la arteria en sus dos túnicas externas: media y adventicia.}
\label{taula:param}
%\setfloatalignment{t}
\end{table}
\begin{table}
\centering
\rowcolors{2}{}{lightgray!20}
\begin{tabularx}{3.2in}{@{\kern\tabcolsep} lYS[table-format=4.4]<{\kern\tabcolsep}}
\toprule
\multicolumn{2}{c}{Propiedades materiales} & Valor \\
\midrule
\cellcolor{lightgray!20} %%% remove this if you don't want
& $\rho_s$ & \SI{1060}{[\kilo\gram\per\metre^3]} \\
\multirow{-2}{*}{\rotatebox{90}{{\cellcolor{lightgray!20}\footnotesize Sangre}}}& $\mu_{s}$ & \SI{3.8e-6}{[\metre^2\per\second]} \\
\midrule
\rowcolor{white} \multicolumn{3}{c}{Modelo hiperelástico de Mooney-Rivlin}\\
\midrule
\cellcolor{lightgray!20}
\cellcolor{lightgray!20}& $C_1$ & \SI{0.020}{[\mega\pascal]} \\
\cellcolor{lightgray!20}& $C_2$ & \SI{0.003}{[\mega\pascal]} \\
\cellcolor{lightgray!20}& $C_3$ & \SI{0.175}{[\mega\pascal]} \\
\cellcolor{lightgray!20}& $C_4$ & \SI{0.090}{[\mega\pascal]} \\
\cellcolor{lightgray!20}& $C_5$ & \SI{0}{[\mega\pascal]} \\
\multirow{-6}{*}{\rotatebox{90}{{\footnotesize Arteria}}}& $C_6$ & \SI{0}{[\mega\pascal]} \\
\midrule
\multicolumn{3}{c}{Modelo hiperelástico de Mooney-Rivlin}\\
\midrule
\cellcolor{lightgray!20}
\cellcolor{lightgray!20}& $C_1$ & \SI{-0.452}{[\mega\pascal]} \\
\cellcolor{lightgray!20}& $C_2$ & \SI{0.510}{[\mega\pascal]} \\
\cellcolor{lightgray!20}& $C_3$ & \SI{0.101}{[\mega\pascal]} \\
\cellcolor{lightgray!20}& $C_4$ & \SI{1.256}{[\mega\pascal]} \\
\cellcolor{lightgray!20}& $C_5$ & \SI{0}{[\mega\pascal]} \\
\multirow{-6}{*}{\rotatebox{90}{{\cellcolor{lightgray!20}\footnotesize Placa}}}& $C_6$ & \SI{0.301}{[\mega\pascal]} \\
\bottomrule
\end{tabularx}
\caption[Parámetros materiales de la sangre, arteria y placa]{Parámetros materiales de la sangre, arteria y placa que los definen como materiales para COMSOL.}
\label{taula:sangue}
\end{table}
\end{document}
我在第一列和最后一列中引入了一些\kern
。为了使文本在颜色上旋转,我已将\multirow
行数减为负数,例如
\multirow{-2}{*}....
最后,我习惯\cellcolor
在合适的位置只填充一个单元格。如果你不想为有多行的第一列着色,请\cellcolor{lightgray!20}
从这些单元格中删除
\midrule
& $C_1$ & \SI{0.020}{[\mega\pascal]} \\
& $C_2$ & \SI{0.003}{[\mega\pascal]} \\
& $C_3$ & \SI{0.175}{[\mega\pascal]} \\
& $C_4$ & \SI{0.090}{[\mega\pascal]} \\
& $C_5$ & \SI{0}{[\mega\pascal]} \\
\multirow{-6}{*}{\rotatebox{90}{{\footnotesize Arteria}}}& $C_6$ & \SI{0}{[\mega\pascal]} \\
\midrule
要得到
答案2
环境{NiceTabular}
具有nicematrix
内置工具来为行、列和单元格着色,并且与直接兼容booktabs
。
\documentclass{article}
\usepackage{ragged2e}
\usepackage{nicematrix}
\usepackage{booktabs}
\usepackage[per-mode=symbol]{siunitx}
\begin{document}
\begin{table}
\centering
\begin{NiceTabular}{cS[table-format=4.4]}
\CodeBefore
\rowcolors{2}{}{lightgray!20}
\Body
\toprule
Propiedades materiales en la media & Valor \\
\midrule
$c_M$ & \SI{3.0}{[\kilo\pascal]} \\
$k_{1_M}$ & \SI{2.3632}{[\kilo\pascal]} \\
$k_{2_M}$ & \num{0.8393} \\
$\beta_M$ & \ang{29.0} \\
$\kappa_M$ & \SI{1000}{[\mega\pascal]}\\
\midrule
Propiedades materiales en la adventicia & Valor \\
\midrule
$c_A$ & \SI{0.3}{[\kilo\pascal]} \\
$k_{1_A}$ & \SI{0.5620}{[\kilo\pascal]} \\
$k_{2_A}$ & \num{0.7112} \\
$\beta_A$ & \ang{62.0} \\
$\kappa_A$ & \SI{1000}{[\mega\pascal]} \\
\bottomrule
\end{NiceTabular}
\caption[Parámetros materiales de la arteria]{Parámetros materiales de la arteria en sus dos túnicas externas: media y adventicia.}
\label{taula:param}
\end{table}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。
对于第二张表。
\documentclass{article}
\usepackage{ragged2e}
\usepackage{nicematrix}
\usepackage{booktabs}
\usepackage[per-mode=symbol]{siunitx}
\begin{document}
\begin{table}
\centering
\begin{NiceTabular}{llS[table-format=4.4]}
\CodeBefore
\rowcolors{2-3}{}{lightgray!20}[cols={2,3}]
\rowcolors{5-10}{lightgray!20}{}[cols={2,3}]
\rowcolors{12-17}{lightgray!20}{}[cols={2,3},restart]
\Body
\toprule
& Propiedades materiales & Valor \\
\midrule
\Block{2-1}{\rotate \footnotesize Sangre}
& $\rho_s$ & \SI{1060}{[\kilo\gram\per\metre^3]} \\
& $\mu_{s}$ & \SI{3.8e-6}{[\metre^2\per\second]} \\
\midrule
\Block{1-3}{Modelo hiperelástico de Mooney-Rivlin}\\
\midrule
\Block{6-1}{\rotate\footnotesize Arteria}
& $C_1$ & \SI{0.020}{[\mega\pascal]} \\
& $C_2$ & \SI{0.003}{[\mega\pascal]} \\
& $C_3$ & \SI{0.175}{[\mega\pascal]} \\
& $C_4$ & \SI{0.090}{[\mega\pascal]} \\
& $C_5$ & \SI{0}{[\mega\pascal]} \\
& $C_6$ & \SI{0}{[\mega\pascal]} \\
\midrule
\Block{1-3}{Modelo hiperelástico de Mooney-Rivlin}\\
\midrule
\Block{6-1}{\rotate \footnotesize Placa}
& $C_1$ & \SI{-0.452}{[\mega\pascal]} \\
& $C_2$ & \SI{0.510}{[\mega\pascal]} \\
& $C_3$ & \SI{0.101}{[\mega\pascal]} \\
& $C_4$ & \SI{1.256}{[\mega\pascal]} \\
& $C_5$ & \SI{0}{[\mega\pascal]} \\
& $C_6$ & \SI{0.301}{[\mega\pascal]} \\
\bottomrule
\end{NiceTabular}
\caption[Parámetros materiales de la sangre, arteria y placa]{Parámetros materiales de la sangre, arteria y placa que los definen como materiales para COMSOL.}
\label{taula:sangue}
\end{table}
\end{document}