1

I have the below code:

\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}

I was hoping to align the three labels for the nodes, as well as put brackets around them and $\textbf{X}$ underneath but am not sure how to do so.

Thanks.

2

Use \strut into your node label content.

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}

EDIT

An addendum to place nodes label below and put square brackets around them:

strut 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}

EDIT 2

Trying to fit OP's demand:

strut 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}
7
  • Thanks, any idea on how to add the label under the three nodes and/or how to put square brackets around them?
    – AW27
    May 10 at 12:55
  • I edited my post accordingly.
    – SebGlav
    May 10 at 13:27
  • Sorry, I meant square brackets around the length of the nodes, leaving the labels at the top of the three nodes, and one more label at the bottom, centred between the three.
    – AW27
    May 10 at 13:30
  • I tried to fit your needs. Please, if it's not what you want, provide a sketch of what you're looking for.
    – SebGlav
    May 10 at 15:21
  • 1
    OK, so what I provided is OK, at this particular moment (except for the dot on the X, which you can add without any problem). I suggest that you work on it a bit and come later with another question if needed, linking this one to provide context. And you may accept my answer if it suits you well for now.
    – SebGlav
    May 10 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.