在 tikz 表中添加单个列行字段

在 tikz 表中添加单个列行字段

如何添加单行列 tikz 表字段,比如在 A2 和 A3 上方中间,将两个右列组合在一起?

\documentclass[12pt,twoside]{report}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{matrix,shadings,arrows,decorations.markings,decorations.pathmorphing}
\tikzset{
    table/.style={
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        nodes={
            rectangle,
            draw=black,
            align=center,
                        text width=10em,
                        fill=gray!10,
                   },
                        %baseline={([yshift=-0.5ex]current bounding box.center)},
        %minimum height=1.0em,
        %text depth=0.2em,
        %text height=0.8em,
                %text centered,
        nodes in empty cells,
                row 1/.style={nodes={fill=black, text=white, font=\bfseries}},
                row 2/.style={nodes={text height=3.3ex}},
            }
        }


\begin{document}

Hello World...
\begin{table}
\centering
\begin{tikzpicture}
\matrix[table, ampersand replacement=\&] (TabA1)
{
A1 \& A2 \& A3 \\
B1 \& $10^{2^{3^{4^{5}}}}$ \& B3 \\
};
\end{tikzpicture}
\caption{Glossary}
\label{tabA1}
\end{table}


\end{document}

答案1

一种可能性是使用 fit 来实现这一点。

\documentclass[12pt,twoside]{report}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{matrix,shadings,arrows,decorations.markings,decorations.pathmorphing,fit}
\tikzset{
    table/.style={
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        nodes={
            rectangle,
            draw=black,
            align=center,
                        text width=10em,
                        fill=gray!10,
                   },
                        %baseline={([yshift=-0.5ex]current bounding box.center)},
        %minimum height=1.0em,
        %text depth=0.2em,
        %text height=0.8em,
                %text centered,
        nodes in empty cells,
                row 1/.style={nodes={fill=black, text=white, font=\bfseries}},
                row 2/.style={nodes={text height=3.3ex}},
            }
        }


\begin{document}

Hello World...
\begin{table}
\centering
\begin{tikzpicture}
\matrix[table, ampersand replacement=\&] (TabA1)
{
A1 \& A2 \& A3 \\
B1 \& $10^{2^{3^{4^{5}}}}$ \& B3 \\
};
\node[fit=(TabA1-1-2) (TabA1-1-3),yshift=16pt,draw,inner sep=-\pgflinewidth/2,
minimum height=24pt]{I fit two nodes};
\end{tikzpicture}
\caption{Glossary}
\label{tabA1}
\end{table}

\end{document}

在此处输入图片描述

相关内容