3

I want to write this picture in LaTeX:

three nodes

I have the following code so far:

\documentclass{standalone}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc,positioning}

\begin{document}

\tikzstyle{block} = [rectangle, draw, fill=blue!20, text width=20em, text centered, rounded corners, minimum height=4em]

\begin{tikzpicture}
\node [block] (V1) {There was a machine in the kitchen};
\node [block, below right=of V1] (V2) {which could extract the juice of two hundred oranges in half an hour};
\node [block, below right=of V2] (V3) {if a little button was pressed two hundred times by a butler's thumb.};
\end{tikzpicture}

\end{document}

which renders: enter image description here

Can anyone please help me with adding the diagonal lines/arrows? Thanks a lot!

2 Answers 2

7

You can draw a line between southeast and northwest points of the nodes.

I added a negative shorten to touch the node's rounded corners.

As Zarko noted, tikzstyle is obsolete, use tikzset instead.

\documentclass[border=2pt]{standalone}
%\usepackage[utf8]{inputenc} no more needed in up-to-date distributions

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc,positioning}
\tikzset{myline/.style={shorten > = -2pt, shorten < = -2pt},
block/.style={rectangle, draw, fill=blue!20, text width=20em, text centered, rounded corners, minimum height=4em}
}
\begin{document}
\begin{tikzpicture}
\node [block] (V1) {There was a machine in the kitchen};
\node [block, below right=of V1] (V2) {which could extract the juice of two hundred oranges in half an hour};
\node [block, below right=of V2] (V3) {if a little button was pressed two hundred times by a butler's thumb.};
\draw[myline] (V1.south east) -- (V2.north west);
\draw[myline] (V2.south east) -- (V3.north west);
\end{tikzpicture}

\end{document}

enter image description here

5
  • As supplement to nice @CarLaTeX answer (+1).
  • Removed all obsolete TikZ syntax (\tikzstyle, text centered).
  • Picture styles defined as options of tikzpicture.
  • Added labels to node as they are in question shown in image of the desired result.
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}
                
\begin{document}
    \begin{tikzpicture}[
node distance = 4mm and 4mm,
   arr/.style = {semithick, shorten > = -2pt, shorten < = -2pt},
   box/.style = {draw, rounded corners, fill=blue!20, font=\large,
                 text width=20em, align=center, minimum height=3em},
every label/.style = {text=cyan, align=left, anchor=south east, xshift=-1em}
                    ]
\node [box, label=north east:main clause] (V1) {There was a machine in the kitchen};
\node [box, label=north east:subordinate clause - relative\\ (what machine?),
            below right=of V1] (V2) {which could extract the juice of two hundred oranges in half an hour};
\node [box, label=north east:subordinate clause - conditional\\
            (under which conditions\\ could the machine do it?),
            below right=of V2] (V3) {if a little button was pressed two hundred times by a butler's thumb.};
\draw[arr]  (V1.south east) edge (V2.north west)
            (V2.south east) edge (V3.north west);
    \end{tikzpicture}
\end{document}

enter image description here

1
  • I didn't notice the tikzstyle, corrected in my answer, too.
    – CarLaTeX
    Nov 12, 2022 at 10:36

You must log in to answer this question.

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