# Create Tikz Picture With These Specifications

Ciao, I am trying to create a tikz figure as shown in the image. Here is my code

\documentclass[border=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning}
\begin{document}
\begin{tikzpicture}[
\node[rectangle] (a1) {box 1};
\node[rectangle,below right=of a1] (a2) {box 2};
\node[rectangle,above right=of a1] (a3) {box 3};

\foreach \i/\j/\txt/\p in {% start node/end node/text/position
a1/a2/1-2/below,
a1/a3/1-3/above,
a2/a3/2-3/below} \draw [myarrow] (\i) -- node[sloped,font=\small,\p] {\txt} (\j);
\end{tikzpicture}
\end{document}


I am not sure how to add the rectangles; how to connect the arrows to the side edge; and how to make the arrows straight in situations when the box lengths are different--preferably the arrows will touch the center of the edge.

New contributor
victoria is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Use Tikz shapes library and describe the sides of nodes.

\documentclass[margin=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,shapes}
\begin{document}

\begin{tikzpicture}[>=latex]
\tikzstyle{rect}=[ thick, draw=blue, rectangle, minimum width=100pt,
minimum height = 50pt, align=center]
\node[rect] (a1) {box 1};
\node[rect,below right=of a1] (a3) {box 3};
\node[rect,above right=of a1] (a2) {box 2};
\draw[->] (a1.north)--(a2.west)node[midway,above,xshift=-2mm]{1-2};
\draw[->] (a1.south)--(a3.west)node[midway,below,xshift=-2mm]{1-3};
\draw[->] (a2.south)--(a3.north)node[midway,xshift=-3mm]{2-3};

\end{tikzpicture}
\end{document}


• thanks a bunch. Two final questions; how can i slant 1-3 and 1-2 so they are angled with the arrows lines? Like this: i.stack.imgur.com/Dwv1Y.png – victoria Jan 10 at 13:52
• @victoria, your welcome. Add sloped option to node, i.e, node[midway,sloped,above,xshift=-2mm]{1-2};Now you can remove the xshift=-2mm. – ferahfeza Jan 10 at 13:55