TikZ 矩阵具有虚线节点边框,但不在第一行

TikZ 矩阵具有虚线节点边框,但不在第一行

是否可以使第一行具有无虚线边框,而其余列的边框为虚线,而不绘制线条\draw

\documentclass{book} 
\usepackage{tikz}
\usetikzlibrary{matrix}

\tikzset{
    matrstandard/.style={
        matrix of nodes,
        nodes in empty cells,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
    }, 
    nodostandard/.style={
        text height=1.75ex, 
        text depth=.25ex,
    },
}

\begin{document} 
\begin{center}
    \begin{tikzpicture}
        \matrix[matrstandard,
            nodes={draw=gray, nodostandard, anchor=base},
            row 1/.style={
                nodes={draw=gray, fill=gray!50!white,font=\bfseries, text centered}},
            row 5/.style={nodes={font=\small, text height=2.5ex}},
            column 1/.style={
                nodes={draw=gray, fill=gray!50!white,font=\bfseries, align=left, text width=1em}},
            column 2/.style={nodes={align=left, dotted, text width=4em}},
            column 3/.style={nodes={align=left, dotted, text width=3em}},
            column 4/.style={nodes={align=right, dotted, text width=3em}},
            column 5/.style={nodes={align=right, dotted, text width=4em}},
            column 6/.style={nodes={align=right, dotted, text width=4em}},
            ] (M) {
            & Name & Sex & Age &Height &Weight\\
            1 & Alfred & M & 14 & 69 & 112.5 \\
            2 & Alice & F & 13 & 56.5 & 84 \\
            3 & Barbara & F & 13 & 65.3 & 98 \\
            \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
        };
    \end{tikzpicture}
\end{center} 
\end{document}

在此处输入图片描述

PS = 我知道布局很差,但我正在尝试复制它(SAS Enterprise Guide 显示的数据集):

在此处输入图片描述

答案1

抱歉,我发布问题后立即找到了解决方案(但这也许对其他人有用)。

solid在第一行中用作节点选项就足够了:

\documentclass{book} 
\usepackage{tikz}
\usetikzlibrary{matrix}

\tikzset{
    matrstandard/.style={
        matrix of nodes,
        nodes in empty cells,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
    }, 
    nodostandard/.style={
        text height=1.75ex, 
        text depth=.25ex,
    },
}

\begin{document} 
\begin{center}
    \begin{tikzpicture}
        \matrix[matrstandard,
            nodes={draw=gray, nodostandard, anchor=base},
            row 1/.style={
                nodes={draw=gray, solid, fill=gray!50!white,font=\bfseries, text centered}},
            row 5/.style={nodes={font=\small, text height=2.5ex}},
            column 1/.style={
                nodes={draw=gray, fill=gray!50!white,font=\bfseries, align=left, text width=1em}},
            column 2/.style={nodes={align=left, dotted, text width=4em}},
            column 3/.style={nodes={align=left, dotted, text width=3em}},
            column 4/.style={nodes={align=right, dotted, text width=3em}},
            column 5/.style={nodes={align=right, dotted, text width=4em}},
            column 6/.style={nodes={align=right, dotted, text width=4em}},
            ] (M) {
            & Name & Sex & Age &Height &Weight\\
            1 & Alfred & M & 14 & 69 & 112.5 \\
            2 & Alice & F & 13 & 56.5 & 84 \\
            3 & Barbara & F & 13 & 65.3 & 98 \\
            \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
        };
    \end{tikzpicture}
\end{center} 
\end{document}

在此处输入图片描述

相关内容