10 使用宏包colortbl如何实现对multirow添加颜色,并且不遮盖表格线的绘制?

发布于 2024-09-23 20:13:54

初次使用colortbl,遇到一些小问题...

image.png

  • 如何对使用colortbl宏包实现对multicol以及multirow添加颜色而不导致遮挡现象
  • 指定列格式遮盖了对行横线颜色的修改,如何让带颜色的横线显示在灰色阴影之上

What is the best practice?

Here below is the mwe..

\documentclass[12pt]{ctexart}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{tabularray}
\begin{document}
    \begin{tabular}{|c|*{3}{>{\columncolor[gray]{.9}}c|}}
        \hline
        \rowcolor{cyan}
        $\beta$ & $50$ & $100$ & $150$ \\
        \hiderowcolors
        \hline
        \cellcolor{orange!60}
        \multirow{2}{*}{静态工作点} & AAA & BBB & CCC \\
        \arrayrulecolor{red}
        \cline{2-4}
        \arrayrulecolor{black}
        \cellcolor{orange!60}% difficulty with multirow...
        & DDD & EEE & FFF \\
        \hline
        \multirow{2}{*}{动态工作点} & AAA & BBB & CCC \\
        \arrayrulecolor{cyan}
        \cline{2-4}
        \arrayrulecolor{black}
        & DDD & EEE & FFF \\
        \hline
        \multirow{2}{*}{等离子态工作点} & AAA & BBB & CCC \\
        \arrayrulecolor{violet}
        \cline{2-4}
        \arrayrulecolor{black}
        & DDD & EEE & FFF \\
        \hline
    \end{tabular}
\end{document}

查看更多

关注者
0
被浏览
495
远方不远
远方不远 2024-09-23
这家伙很懒,什么也没写!

其实非常简单,只要把合并单元格挪到下面一格就行了,multirow支持反向合并,而tabularray完全都是另一种思路了,针灸无脑推...

\documentclass[12pt]{ctexart}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{tabularray}
\begin{document}
    \begin{tabular}{|c|*{3}{>{\columncolor[gray]{.9}}c|}}
        \hline
        \rowcolor{cyan}
        $\beta$ & $50$ & $100$ & $150$ \\
        \hiderowcolors
        \hline
        \cellcolor{orange!60}
        & AAA & BBB & CCC \\
        \arrayrulecolor{red}
        \cline{2-4}
        \arrayrulecolor{black}
        \cellcolor{orange!60}% difficulty with multirow...
        \multirow{-2}{*}{静态工作点} & DDD & EEE & FFF \\
        \hline
        \multirow{2}{*}{动态工作点} & AAA & BBB & CCC \\
        \arrayrulecolor{cyan}
        \cline{2-4}
        \arrayrulecolor{black}
        & DDD & EEE & FFF \\
        \hline
        \multirow{2}{*}{等离子态工作点} & AAA & BBB & CCC \\
        \arrayrulecolor{violet}
        \cline{2-4}
        \arrayrulecolor{black}
        & DDD & EEE & FFF \\
        \hline
    \end{tabular}
\end{document}
2 个回答
Sagittarius Rover
Sagittarius Rover 2024-09-23
我要成为TikZ糕手/(ㄒoㄒ)/~~

我来自己提供一个tabularray的方法....

image.png

%\usepackage{xcolor}
%\usepackage{tabularray}
\begin{tblr}{
        hlines,
        vlines,
        colspec = {cQ[c,cyan7]Q[c,azure7]Q[c,blue7]},
        row{1} = {bg=cyan},
        hline{3} = {2-4}{red},
        hline{5} = {2-4}{cyan},
        hline{7} = {2-4}{violet},
        cell{2}{1} = {r=2,c=1}{c,orange!60},
        cell{4}{1} = {r=2,c=1}{c,orange!60},
        cell{6}{1} = {r=2,c=1}{c,orange!60},
    }
        $\beta$ & $50$ & $100$ & $150$ \\
        静态工作点& AAA & BBB & CCC \\
        & DDD & EEE & FFF \\
        动态工作点& AAA & BBB & CCC \\
        & DDD & EEE & FFF \\
        等离子态工作点& AAA & BBB & CCC \\
        & DDD & EEE & FFF \\
\end{tblr}

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览