# A Basic TikZ Drawing

I've not yet had enough experience drawing in TikZ to be able to do it quickly. I also find the manual a bit daunting -- though if I had time, I'm sure it does a fabulous job explaining everything I would ever need to know.

However, at the moment I don't have time to learn all of it, so I'm asking for help instead. What I want would look like this (with the lines solid, rather than crappy, as I've drawn them here):

        |
Text4  |  Text1
------------------
Text3  |  Text2
|


But, in addition, I would like a circular arrow that started to the upper right of "Text1" and went around until it stopped (with an arrow head) above and to the left of "Text4."

Ok. I hope that was sufficiently clear. I'm slowly coming to understand the syntax here; you all have been wonderful about putting up with me thus far and I greatly appreciate it.

• Should those four text parts and the cross (the lines) be one node, similar to Four Colored Circle Split? The arrow can be easily drawn either with a to path (bend right or in and out keys (see “63.3 Curves”, pp. 469) or an arc with calculated start and end angles. If you only want to specify a radius and an target point you also might find joining points on a circle worth reading. Sep 7 '13 at 22:35
• The Qrr; those were indeed helpful articles.
– Shay
Sep 10 '13 at 0:32

The four labels and the perpendicular lines are easy to draw. You can use a matrix of nodes, for example:

\matrix[matrix of nodes, name=M, nodes={minimum height=1.2cm}] {
Text 4 & Text 1 \\
Text 3 & Text 2 \\
};
\draw (M.north) -- (M.south) (M.east) -- (M.west);


The circular arrow is more difficult, specially if you require a real circle (i.e: a circular arc). Tikz can draw arcs, but the default syntax requires that you specify the starting point, the starting and end angles, and the radius, which are not obvious nor easy to find from your figure.

I coded a macro called \arcThroughThreePoints (used first in this other answer) which as its name suggests accepts three points and draws the circular path which passes through them. Using this macro is easier to draw your arrow, since the three given points would be the upper right corner of "Text 1", the bottom left corner of "Text 4", and some arbitrary point below the bottom of the whole matrix of nodes. These three points need some manual adjustment to get an arrow which looks good.

This is the complete code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}
\newcommand{\arcThroughThreePoints}[4][]{
\coordinate (middle1) at ($(#2)!.5!(#3)$);
\coordinate (middle2) at ($(#3)!.5!(#4)$);
\coordinate (aux1) at ($(middle1)!1!90:(#3)$);
\coordinate (aux2) at ($(middle2)!1!90:(#4)$);
\coordinate (center) at ($(intersection of middle1--aux1 and middle2--aux2)$);
\draw[#1]
let \p1=($(#2)-(center)$),
\p2=($(#4)-(center)$),
\n1={atan2(\x1,\y1)}, % angles
\n2={atan2(\x2,\y2)},
\n3={\n2>\n1?\n2:\n2+360}
in (#2) arc(\n1:\n3:\n0);
}

\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes, name=M, nodes={minimum height=1.2cm}] {
Text 4 & Text 1 \\
Text 3 & Text 2 \\
};

\draw (M.north) -- (M.south) (M.east) -- (M.west);
% Coordinates for the three points of the circular arc
\coordinate (end) at ($(M.west)+(-0.2,0.2)$);
\coordinate (start) at ($(M.north east)+(-0.2,-0.2)$);
\coordinate (bottom) at ($(M.south)+(0,-0.2)$);
% Draw the arc in red, and with an arrow tip
\arcThroughThreePoints[<-,red]{end}{bottom}{start};
\end{tikzpicture}
\end{document}


Result:

## UPDATE

In this particular case, an easier (and probably better) solution exists, assuming that your four nodes are of the same width, and then your circular arc will be centered in the intersection of the perpendicular lines, i.e: at the matrix center.

In this case we can use polar coordinates to set the starting point at a given angle and distance from that center (say, angle=35, distance=1.6, which roughly coincides at the upper right of "Text 1"). This point can be specified as (M.center) +(35:1.6). Then, the standard syntax for arcs fits very well with the problem, since we know the starting angle for the arc (35), its ending angle (eg. -190) and its radius (1.6). So the clumsy \arcThroughThreePoints macro is not required:

\begin{tikzpicture}
\matrix[matrix of nodes, name=M, nodes={minimum height=1.2cm}] {
Text 4 & Text 1 \\
Text 3 & Text 2 \\
};

\draw (M.north) -- (M.south) (M.east) -- (M.west);
% Draw the arc in red, and with an arrow tip
\draw[red,->] (M.center) +(35:1.6) arc(35:-190:1.6);
\end{tikzpicture}


Resulting in:

• Very helpful; very clear. The updated answer will work quite well, and demonstrates several tikz tricks I'll be able to take with me.
– Shay
Sep 8 '13 at 14:24