2

I am trying to recreate the diagram shown in the picture below using LaTeX.

For reference, I would like to be able to include an image/picture at the top of the diagram (in the picture you'll see my attempt at drawing a car and a tree). Then I want to be able to show a line connecting it to a {word}. And lastly, I'd like to connect that word to other words that are circled around. If possible, I would like to be able to link other diagrams to the words from the original diagram with simply lines, as shown in the picture below.

I would appreciate it if anyone could help me create a diagram like this, thanks!

enter image description here

1 Answer 1

6

You can include graphics in TikZ pictures and forest trees. So just replace example-image-a by an image of a car and example-image-b by an image of a tree.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{forest}
\usetikzlibrary{shapes.geometric,positioning}
\tikzset{elli/.style={ellipse,draw}}
\begin{document}
\begin{forest}
for tree={l sep+=1em,where level=2{elli}{}}
[{\includegraphics[width=1.5cm]{example-image-a}},alias=car
 [{\{word\}},alias=wordL
  [word,alias=elli1]
  [word,alias=elli2]
  [word,alias=elli3]
  [word,alias=elli4]
 ]
]
\node[right=2em of elli4,elli] (elliR) {word};
\node (wordR) at (elliR|-wordL) {{\{word\}}};
\node (tree) at (elliR|-car) {\includegraphics[width=1.5cm]{example-image-b}};
\draw (tree) -- (wordR) foreach \X in {3,4,R}
{(wordR) -- (elli\X)};
\end{forest}
\end{document}

enter image description here

And just for fun: drawing the car and the tree with TikZ.

\documentclass[border=3.14mm]{standalone}
\usepackage{forest}
\usepackage{tikzducks}
\usetikzlibrary{shapes.geometric,positioning}
\usetikzlibrary{decorations.pathmorphing,shapes}
\tikzset{elli/.style={ellipse,draw}}
\newsavebox\Car
\newsavebox\Tree
\begin{document}
\begin{lrbox}{\Car}
\begin{tikzpicture} see https://tex.stackexchange.com/users/101651/carlatex
\fill (-4.7,-0.8) arc(180:0:1.7 and 1.1) --cycle;
\fill (1.3,-0.8) arc(180:0:1.7 and 1.1) --cycle;
% right front wheel
\fill (-3.3,-0.1) circle (1.5cm);
% left front wheel
\shade[inner color=black,outer color=black!70] (-3,-0.7) circle (1.5cm);
\fill[black!20!white] (-3,-0.7) circle (0.8cm);
\foreach \X in {0,30,...,330} {\fill[black] (-3,-0.7) +({\X-5}:0.6) circle (1pt);}
% back wheel
\fill (2.7,-0.1) circle (1.5cm);
% back wheel left
\shade[inner color=black,outer color=black!70] (3,-0.7) circle (1.5cm);
\fill[black!20!white] (3,-0.7) circle (0.8cm);
\foreach \X in {0,30,...,330} {\fill[black] (3,-0.7) +({\X+11}:0.6) circle (1pt);}
% seat
\fill[top color=red,bottom color=red!20!black] (2.9,2.2) arc(0:360:3 and 0.3);
% driver
\begin{scope}[xshift=-2.3cm,yshift=1cm,scale=1.5]
\duck[squareglasses=blue!50!black,longhair=black];
\end{scope}
% right light
\shade[bottom color=red,top color=red!30] (-4.35,1) arc(-90:90:0.3 and 0.4) |-
cycle;
\shade[bottom color=yellow!30,top color=white] (-4.45,1) arc(-90:270:0.1 and
0.4);
% body 
\shade[bottom color=red,top color=red!30] (-4.7,-0.8) arc(180:0:1.7) -- (-1.3,-0.8) -- (1.3,-0.8) arc(180:0:1.7)
-- (4.9,-0.8) arc(0:90:2 and 3) 
arc(0:-180:3 and 0.3)
-- (-2.9,2.2) arc(90:180:2 and 3) -- cycle;
\shade[bottom color=red,top color=red!30] (-4.7,-0.8) arc(180:0:1.7 and 1.1) arc(0:180:1.7 and 1.8);
\shade[bottom color=red,top color=red!30] (1.3,-0.8) arc(180:0:1.7 and 1.1) arc(0:180:1.7 and 1.8);
% door 
\draw[very thin] (1.1,1.9) to[out=-90,in=80] (1,-0.6) -- (-1,-0.6) 
to[out=110,in=-90] (-1.1,1.9);
\node[blue,font=\sffamily\Huge] at (0,0.8) {\LaTeX};
% left light
\shade[bottom color=red,top color=red!30] (-4.4,0.8) arc(-90:90:0.3 and 0.4) |-
cycle;
\shade[bottom color=yellow!30,top color=white] (-4.4,0.8) arc(-90:270:0.1 and
0.4);
% windshield
\shade[bottom color=blue,top color=blue!20,opacity=0.3] 
(-3.2,2.2) arc(180:130:3 and 0.3) arc(180:150:2.5 and 4)
arc(130:180:3 and 0.3) -- cycle;
\shade[bottom color=blue,top color=blue!20,opacity=0.3] 
(-3.2,2.2) arc(180:230:3 and 0.3) arc(180:150:2.5 and 4)
arc(230:180:3 and 0.3) -- cycle;
\end{tikzpicture}
\end{lrbox}%
\begin{lrbox}{\Tree}
\begin{tikzpicture}[treetop/.style = {% from https://tex.stackexchange.com/a/101113/121799
    decoration={random steps, segment length=0.4mm},
    decorate
  },
  trunk/.style = {
    decoration={random steps, segment length=2mm, amplitude=0.2mm},
    decorate
  }]
\foreach \w/\f in {0.3/30,0.2/50,0.1/70} {
  \fill [brown!\f!black, trunk] (0,0) ++(-\w/2,0) rectangle +(\w,-3);
}
\foreach \n/\f in {1.4/40,1.2/50,1/60,0.8/70,0.6/80,0.4/90} {
   \fill [green!\f!black, treetop] ellipse (\n/1.5 and \n);
}
\end{tikzpicture}
\end{lrbox}%

\begin{forest}
for tree={l sep+=1em,where level=2{elli}{}}
[{\usebox\Car},scale=0.2,alias=car
 [{\{word\}},alias=wordL
  [word,alias=elli1]
  [word,alias=elli2]
  [word,alias=elli3]
  [word,alias=elli4]
 ]
]
\node[right=2em of elli4,elli] (elliR) {word};
\node (wordR) at (elliR|-wordL) {{\{word\}}};
\node[xscale=0.4,yscale=0.25] (tree) at (elliR|-car) {\usebox\Tree};
\draw (tree) -- (wordR) foreach \X in {3,4,R}
{(wordR) -- (elli\X)};
\end{forest}
\end{document}

enter image description here

No worries, this is an electric car, so the tree should be fine, and it is safe to use forest.

2
  • 1
    The car is really pretty! :):):)
    – CarLaTeX
    Commented May 13, 2019 at 7:29
  • This is exactly what I was looking for, thanks!
    – Ernesto
    Commented May 13, 2019 at 8:46

You must log in to answer this question.

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