The code below draws three nested rectangles. Then I want to add text by using a node. Somehow the coordinates of the rectangles are not in line with the coordinates of the nodes. To place some text in the largest rectangle, I would assume, that (0.5, -0.5) would do the job. But now the text is outside of the rectangle. But why? How can I put each paragraph in the upper left corner of each rectangle? Are there better ways to do it?



\def\xa{(0,0)} \def\ya{(15.0,-5)}
\def\xb{(5,-0.2)} \def\yb{(14.8,-4.8)}
\def\xc{(10,-0.4)} \def\yc{(14.6,-4.6)}

    % Draw boxes
    \draw \xa rectangle \ya ;
    \draw \xb rectangle \yb;
    \draw \xc rectangle \yc;
    \node at (0.5,-0.5) [text width=4cm] {\tiny\lipsum[66]};
    \node at (6,-2) [text width=4cm] {\tiny\lipsum[66]};
    \node at (10,-2) [text width=4cm] {\tiny\lipsum[66]};


enter image description here

1 Answer 1


like this?

enter image description here

for above image are used only nodes (this is more simple than draw rectangles and than nested nodes with text). text nodes are positioned relatively to each, drawing by use of library fit:

\documentclass[tikz, border=10]{standalone}
\usetikzlibrary{fit, positioning}

    node distance = 0mm and 1mm,
box/.style = {text width=4cm, font=\tiny},  % define nodes style
\node (n1) [box,draw] {\lipsum[66]};
\node (n2) [box,left=of n1] {\lipsum[66]};
\node (n3) [box,left=of n2] {\lipsum[66]};
\node (n4) [draw,fit=(n1) (n2)] {};
\node (n5) [draw,fit=(n3) (n4)] {};


note: font size is defined in node style. by this the baseline skip in node consider the selected font size.

  • Where is the rectangle defined in the code? What about nodes n4 and n5?
    – Gilfoyle
    Dec 7, 2018 at 9:54
  • 1
    @Samuel, rectangles are defined in tikzpicture preamble. style name is box. nodes n4 and n5 provides lines around nodes listed in fit options (around nodes n1 and n2 and n3 and n4). node name n5 actually is not necessary ...
    – Zarko
    Dec 7, 2018 at 10:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .