0

I am trying to draw the following graph on Latex using Tikz:

enter image description here

I want the caption of the figure to be below.

I have been using the following codes:

\begin{figure}
\centering
\begin{tikzpicture}[>=latex] 
\node[mybox] (Adam) [below left =of Charlie, fill=red!30] {\textbf{Adam}\\ Wants morning bread}edge [->] node[left=10pt,name=CA] {Strawberries} (Charlie) ;
\node[mybox] (Betty) [below right =of Charlie, fill=blue!30] {\textbf{Betty}\\ Wants afternoon bread}edge [->] node[below=10pt,name=AB] {Tangerines} (Adam) edge[<-] node[right=10pt,name=BC] {Apples} (Charlie) ;
\end{tikzpicture}
\caption{Lack-of-double-coincidence-of-wants problem}

But I am getting this output:

enter image description here

So any help would be appreciated on showing me how to draw the above figure. The caption of the figure is fine because I prefer it to be below.

4

I feel you would be better off if you posted a complete minimal working example, and refer to the earlier posts that you intend to keep using. This answer provides working codes and links (and in case someone shows up stating things become so much simpler when using quotes: please take such statements with a grain of salt ;-). I added two versions, one with straight arrows, and one with bent arrows (which I personally like better), and also slightly modified the mybox style from this answer.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc}
\tikzset{% from https://tex.stackexchange.com/a/514738/194703
    mybox/.style={rounded rectangle,draw=black,align=center,inner ysep=1ex,
    execute at begin node=\strut},
}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[>=latex,font=\sffamily] 
\node[mybox] (Adam)  {\textbf{Adam}\\ Wants morning bread};
\node[mybox] (Betty) [right =of Adam, fill=blue!30] 
    {\textbf{Betty}\\ Wants afternoon bread}
([yshift=-1.2em]Betty.west) edge[thick,->] node[below=1ex,name=BA] {Produces Night Bread} 
([yshift=-1.2em]Adam.east)  
([yshift=1.2em]Adam.east)    edge [thick,->] node[above=1ex,name=AB] {Produces
Morning Bread} 
([yshift=1.2em]Betty.west);
\end{tikzpicture}
\caption{Lack-of-double-coincidence-of-wants problem.}
\end{figure}

\begin{figure}[htb]
\centering
\begin{tikzpicture}[>=latex,font=\sffamily] 
\node[mybox] (Adam)  {\textbf{Adam}\\ Wants morning bread};
\node[mybox] (Betty) [right =of Adam, fill=blue!30] 
    {\textbf{Betty}\\ Wants afternoon bread}
([yshift=-1em]Betty.west) edge[thick,->,bend left] node[below=1ex,name=BA] {Produces Night Bread} 
([yshift=-1em]Adam.east)    
([yshift=1em]Adam.east)  edge [thick,->,bend left] node[above=1ex,name=AB] {Produces
Morning Bread} 
([yshift=1em]Betty.west);
\end{tikzpicture}
\caption{Lack-of-double-coincidence-of-wants problem.}
\end{figure}
\end{document}

enter image description here

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.