1

The following question is a follow-up to that post.

Assume five nodes, arranged in three rows. I would like to arrange these nodes in the following pattern:

|----Node A----|  |Node B|
|Node C||Node D|
|----Node E----|

Controlling the position of node E is not very intuitive to me.

Using anchor=north west results in an incorrect horizontal position:

\node [block_large, below=0.1cm of col1_row2, anchor=north west] (col1_row3) {
    \textbf{Node E}\\
    \textit{Foo:} Bar\\
    \textit{Baz:} Qux
};

Adding a right shift (right=-2.11) results in an incorrect vertical position:

\node [block_large, below=0.1cm of col1_row2, anchor=north west, right=-2.11] (col1_row3) {
    \textbf{Node E}\\
    \textit{Foo:} Bar\\
    \textit{Baz:} Qux
};

How do you re-establish the alignment for node E?

3

You can still follow the relative positioning. I cleaned up the irrelevant parts a bit.

\documentclass[tikz]{standalone}
\tikzset{block large/.style={rectangle, draw, text width=8cm, inner xsep=0.25cm, 
        rounded corners, text height=0.4cm, text depth=1.25cm, 
        node contents=\mycontent{#1},name=#1
    },
    block medium/.style = {block large=#1,text width=3.75cm}
}
\def\mycontent#1{
            \textbf{Node #1}\\
            \textit{Foo:} Bar\\
            \textit{Baz:} Qux
}
\begin{document}
\begin{tikzpicture}
\node[block large =A];
\node[block medium=B,anchor=north west,at={([yshift=-1mm]A.south west)}]; 
\node[block medium=C,anchor=north east,at={([yshift=-1mm]A.south east)}]; 
\node[block large =E,anchor=north west,at={([yshift=-1mm]B.south west)} ];
\end{tikzpicture}
\end{document}

enter image description here

0
1

And with a similar code from my answer to your previous question you can also get this alignment with tcolorboxes.

\documentclass{article}
\usepackage[most]{tcolorbox}

\newcommand{\mytext}[1]{\textbf{Node #1}\\\textit{Foo:} Bar\\\textit{Baz:} Qux}

\begin{document}
\begin{tcbitemize}[raster equal height=rows, raster columns=3, notitle, colback=white]
\tcbitem[raster multicolumn=2] \mytext{A}
\tcbitem \mytext{B}
\tcbitem \mytext{C}
\tcbitem \mytext{D}
\tcbitem[blankest] %We need an empty box to count three in a row
\tcbitem[raster multicolumn=2] \mytext{E}
\end{tcbitemize}
\end{document}

enter image description here

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.