3

I have this code

\documentclass[10pt]{article}
\begin{document}
\tikzset{
    solid node/.style={circle,draw,inner sep=1.5,fill=black},
    hollow node/.style={circle,draw,inner sep=1.5}
}
\begin{tikzpicture}[grow = right, scale=1.5,font=\footnotesize]
    \tikzstyle{level 1}=[level distance=15mm, sibling distance=15mm]
    \tikzstyle{level 2}=[level distance=15mm, sibling distance=15mm]
    \tikzstyle{level 3}=[level distance=15mm, sibling distance=15mm]

    % The Tree
    \node(0)[solid node,label=left:{$N$}]{} 
    child{node(1)[solid node, white]{}
    }
    child{[white] node(2)[solid node, xshift=20]{}  %note that you need to adjust the yshift if you change the sibling distance
    child{[black] node[hollow node,label=right:{$(a,b)$}]{} edge from parent node[below]{$C$}}
    child{[black] node[hollow node,label=right:{$(c,d)$}]{} edge from parent node[above]{$D$}}
    edge from parent node[black, xshift=40,yshift=0]{$\alpha$} %note that you need to adjust the yshift if you change the level distance
    }
    child{node(3)[solid node, white]{}
    };
    % information set
    \draw[solid,bend right](1)to(3);
    \draw[dashed,rounded corners=7]($(1)+(.25,-.25)$)rectangle($(3)+(-.25,.25)$);
    \end{tikzpicture}
    \end{document}

that produces this tree

enter image description here

How can I bend to the right the rectangle? I have tried this code:

\draw[dashed,rounded corners=7, bend right]($(1)+(.25,-.25)$)rectangle($(3)+(-.25,.25)$);

But it's not working! Any idea? Thanks!

  • 3
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Stefan Pinnow Mar 12 at 16:32
3

Like this?

screenshot

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc}
\tikzset{
    solid node/.style={circle,draw,inner sep=1.5,fill=black},
    hollow node/.style={circle,draw,inner sep=1.5}
}
\begin{document}
\begin{tikzpicture}[grow = right, scale=1.5,font=\footnotesize]
    \tikzstyle{level 1}=[level distance=15mm, sibling distance=15mm]
    \tikzstyle{level 2}=[level distance=15mm, sibling distance=15mm]
    \tikzstyle{level 3}=[level distance=15mm, sibling distance=15mm]

    % The Tree
    \node(0)[solid node,label=left:{$N$}]{} 
    child{node(1)[solid node, white]{}
    }
    child{[white] node(2)[solid node, xshift=20]{}  %note that you need to adjust the yshift if you change the sibling distance
    child{[black] node[hollow node,label=right:{$(a,b)$}]{} edge from parent node[below]{$C$}}
    child{[black] node[hollow node,label=right:{$(c,d)$}]{} edge from parent node[above]{$D$}}
    edge from parent node[black, xshift=40,yshift=0]{$\alpha$} %note that you need to adjust the yshift if you change the level distance
    }
    child{node(3)[solid node, white]{}
    };
    % information set
    \draw[solid,bend right](1)to(3);
    %\draw[dashed,rounded corners=7]($(1)+(.25,-.25)$)rectangle($(3)+(-.25,.25)$);
    \coordinate (a) at ($(1.center)+(-.25,0)$);
    \coordinate (b) at ($(1.center)+(.25,0)$);
    \coordinate (c) at ($(3.center)+(.25,0)$);
    \coordinate (d) at ($(3.center)+(-.25,0)$);
    \draw[dashed,rounded corners=7] (1)--(b)to[bend right](c)--(d)to[bend left](a)--(1);
    \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.