带表格的图形,表格单元格内以及图形注释外部均有文本和背景颜色

带表格的图形,表格单元格内以及图形注释外部均有文本和背景颜色

我正在尝试绘制一个包含 4x3 表格(可能结合了 tikzpicture 和 colortbl)的图形,单元格内有文本和背景颜色(灰度),图形外部有一些注释。我正在寻找类似的东西:

面试级别

但这是迄今为止我能得到的最接近的答案:

    \documentclass[a4paper,12pt]{article}
    \usepackage[left=1.5cm,right=1.5cm,top=1.5cm,bottom=1.5cm,ignoreheadfoot]{geometry}
    \usepackage{array}
    \usepackage[svgnames,table]{xcolor}

    \newcommand*{\arraycolor}[1]{\protect\leavevmode\color{#1}}
    \newcolumntype{A}{>{\columncolor{Gray!22}}c}
    \newcolumntype{B}{>{\columncolor{Gray!42}}c}
    \newcolumntype{C}{>{\columncolor{Gray!72}}c}
    \newcolumntype{D}{>{\columncolor{Gray!92}}c}

    \begin{document}    

    \begin{center}
    \sffamily
    \arrayrulecolor{white}
    \arrayrulewidth=1pt
    \renewcommand{\arraystretch}{1.5}
    \rowcolors[\hline]{3}{.!50!White}{}
    \begin{tabular}{A|B|C|D|}
    \rowcolor{.!50!Black}
    \arraycolor{White}\bfseries & 
    \arraycolor{White}\bfseries A &
    \arraycolor{White}\bfseries B &
    \arraycolor{White}\bfseries C \\
    A & Within 1 & Within 2 & Within 2 \\
    B & Within 2 & Within 1 & Within 2\\
    C & Within 2 & Within 2 & Within 1 \\
    D & Out & Out & Out \\
    \end{tabular}
    \end{center}

    \end{document}

答案1

使用tikzmatrix相对简单:

在此处输入图片描述

\documentclass[tikz, margin=3mm]{standalone}
% temporary fix expl3 changes which not yet propagate to all package used it
\usepackage{expl3}
\ExplSyntaxOn
\int_zero_new:N \g__prg_map_int
\ExplSyntaxOff
% end of temporary fix
\usetikzlibrary{decorations.pathreplacing,
                calligraphy,
                matrix,
                positioning}

\begin{document}
\begin{tikzpicture}[
node distance = 1mm and 3mm,
    BC/.style = {decorate,
    decoration={calligraphic brace, amplitude=3mm,
    raise=#1, mirror}, thick, pen colour={gray}},
                    ]
\matrix (m) [matrix of nodes,
             nodes={draw, minimum size=20mm, outer sep=0pt},
             column sep=-\pgflinewidth,
             row sep=-\pgflinewidth,
             column 1/.style={font=\bfseries},
             row 1/.style={font=\bfseries},
             CB/.style = {fill=black!80, text=white},
             CG/.style = {fill=gray},
             CS/.style = {fill=gray!50},
             ]
{       & A                 & B                 & C         \\
    A   & |[CS]| Within 1   & |[CG]| Within 2   & |[CG]|Within 2  \\
    B   & |[CG]| Within 2   & |[CS]| Within 1   & |[CG]|Within 2  \\
    C   & |[CG]| Within 2   & |[CG]| Within 2   & |[CS]|Within 1  \\
    D   & |[CB]| Out        & |[CB]| Out        & |[CB]|Out \\
};
\node[above=of m-1-3] {\textbf{Answering}};
\node[left =of m-3-1, rotate=90] {\textbf{Questioning}};
\draw[BC= 2mm] (m-4-4.south east) -- node[below= 4mm, sloped] {Partners} (m-1-4.north east);
\draw[BC=11mm] (m-5-4.south east) -- node[below=13mm, sloped] {All Members} (m-1-4.north east);
\end{tikzpicture}
\end{document}

相关内容