0

I need bottom nodes to start where their respective top nodes instead of being centered below them.

Output:

Code:

\begin{tikzpicture}
\node[align=left,draw=black,rounded corners](colOne_rowOne)
{
this is line 1\\
this is line 2, this is line 2
};
\node[below=of colOne_rowOne,align=left,draw=black,rounded corners](colOne_rowTwo)
{
this is line
};
\node[right=of colOne_rowOne,align=left,draw=black,rounded corners](colTwo_rowOne)
{
this is line 1\\
this is line 2, this is line 2
};
\node[below=of colTwo_rowOne,align=left,draw=black,rounded corners](colTwo_rowTwo)
{
this is line
};
\end{tikzpicture}
  • 1
    Please don't post code fragments. Instead, put your fragments into a complete compilable document that shows the problem. So is the problem that you want the smaller boxes left aligned underneath the bigger boxes? – Alan Munn Aug 30 '17 at 1:02
2

While @Zarko's answer is working in this case, I think it is cleaner to use anchors for this:

\begin{tikzpicture}[box/.style={align=left,draw=black,rounded corners}]
    \node[box](colOne_rowOne)
    {
        this is line 1\\
        this is line 2, this is line 2
    };
    \node[box, below=of colOne_rowOne.south west, anchor=north west](colOne_rowTwo)
    {
        this is west-aligned
    };
    \node[box, right=of colOne_rowOne](colTwo_rowOne)
    {
        this is line 1\\
        this is line 2, this is line 2
    };
    \node[box, below=of colTwo_rowOne.south east, anchor=north east](colTwo_rowTwo)
    {
        this is east-aligned
    };
\end{tikzpicture}

Anchors are fitted for this task: they tell which point of the current node should be positioned at the given coordinate. Then you can use the node distance key to change the distances between the nodes.

rendering

2

enter image description here

it is not fun reconstruct the missing preamble: it contain important information for the image drawings ...

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 3mm and 0mm,
box/.style = {shape=rectangle, draw, rounded corners, align=left}
                        ]
\node[box](colOne_rowOne)
        {
        this is line 1\\
        this is line 2, this is line 2
        };
\node[box, below right=of colOne_rowOne.south west](colOne_rowTwo)
        {
        this is line
        };
\node[box, right=6mm of colOne_rowOne](colTwo_rowOne)
        {
        this is line 1\\
        this is line 2, this is line 2
        };
\node[box, below right=of colTwo_rowOne.south west] (colTwo_rowTwo)
        {
        this is line
        };
    \end{tikzpicture}
\end{document}

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.