创建并对齐节点标签,然后在节点下添加方括号和标签

创建并对齐节点标签,然后在节点下添加方括号和标签

我有以下代码:

\usepackage{tikz}

\begin{document}

\maketitle

\section{Introduction}
\usetikzlibrary{fit,positioning,calc,arrows,backgrounds, shapes.misc,snakes}

\begin{tikzpicture}
\node at (0,0)[fill, rounded corners, rectangle, minimum height=6cm, fill = blue, label={$\dot{x}$}] (xdot) {};
\node at (0,0)[fill,rounded corners, rectangle, minimum height=6cm, fill = yellow, right=0.15cm of xdot, label={$\dot{y}$}] (ydot) {};
\node at (0,0)[fill,rounded corners, rectangle, minimum height=6cm, fill = red, right=0.15cm of ydot, label={$\dot{z}$}] (zdot) {};


\end{tikzpicture}
\end{document}

我希望将 的三个标签对齐nodes,并在它们周围加上括号,并在下面加上 $\textbf{X}$,但不确定如何操作。

谢谢。

答案1

使用\strut到您的节点标签内容中。

支撑

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,calc,arrows,backgrounds, shapes.misc,snakes}

\begin{document}

\section{Introduction}

\begin{tikzpicture}
\node at (0,0)[fill, rounded corners, rectangle, minimum height=6cm, fill = blue, label={$\strut \dot{x}$}] (xdot) {};
\node at (0,0)[fill,rounded corners, rectangle, minimum height=6cm, fill = yellow, right=0.15cm of xdot, label={$\strut \dot{y}$}] (ydot) {};
\node at (0,0)[fill,rounded corners, rectangle, minimum height=6cm, fill = red, right=0.15cm of ydot, label={$\strut  \dot{z}$}] (zdot) {};


\end{tikzpicture}
\end{document}

编辑

附录将节点标签放在下方并用方括号括起来:

支柱 2

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,calc,arrows,backgrounds, shapes.misc,snakes}

\begin{document}

\section{Introduction}

    \begin{tikzpicture}
        \node at (0,0)[fill, rounded corners, rectangle, minimum height=6cm, fill = blue, label={[name=X]below:$\strut \dot{x}$}] (xdot) {};
        \node at (0,0)[fill,rounded corners, rectangle, minimum height=6cm, fill = yellow, right=0.15cm of xdot, label={[name=Y]below:$\strut \dot{y}$}] (ydot) {};
        \node at (0,0)[fill,rounded corners, rectangle, minimum height=6cm, fill = red, right=0.15cm of ydot, label={[name=Z]below:$\strut  \dot{z}$}] (zdot) {};
        \node[left=-5pt of X]{$[$};
        \node[right=-5pt of Z]{$]$};
    \end{tikzpicture}
\end{document}

编辑2

尝试满足 OP 的要求:

支柱 v3

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{fit,positioning,calc,arrows,backgrounds, shapes.misc,snakes}

\begin{document}

\section{Introduction}

    \begin{tikzpicture}
        \node at (0,0)[fill, rounded corners, rectangle, minimum height=6cm, fill = blue, label={[name=X]above:$\strut \dot{x}$}] (xdot) {};
        \node at (0,0)[fill,rounded corners, rectangle, minimum height=6cm, fill = yellow, right=0.15cm of xdot, label={[name=Y]above:$\strut \dot{y}$}] (ydot) {};
        \node at (0,0)[fill,rounded corners, rectangle, minimum height=6cm, fill = red, right=0.15cm of ydot, label={[name=Z]above:$\strut  \dot{z}$}] (zdot) {};
        \draw[thick] ($(xdot.north)+(-8pt,0)$) --++(-5pt,0) |- ($(xdot.south)+(-8pt,0)$);
        \draw[thick] ($(zdot.north)+(8pt,0)$) --++(5pt,0) |- ($(zdot.south)+(8pt,0)$);
        \node[below= 0pt of ydot]{\textbf{X}};
    \end{tikzpicture}
\end{document}

相关内容