I'm trying to draw the following picture in LaTeX but I'm having trouble understanding what I should use. I've seen a few examples, but it's hard to adapt them into what I'm looking for.
If you could help, I'd be truly grateful.
Best Answer
Welcome to TeX.SE!
Here is a simple prototype of what you need. Hopefully, you may apply your desired customizations to it.
\documentclass[border=1pt]{standalone}
\usepackage{tikz} %TikZ central library is called.
\usetikzlibrary{automata,positioning} % automata and positioning libraries are required to use nodes and coordinates in addition to placement propetries.
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=1.0cm,on grid,auto] % Some customizations related to the size and the discatnce between nodes and arrow heads
\node[state,rectangle, align=center] (q_r) [] {This is a \\ square}; % Here the nodes and coordinates are defined
\node[coordinate] (q_0) [right=of q_r, xshift=3cm] {};
\node[coordinate] (q_1) [left=of q_r, xshift=-3cm, yshift=1mm] {};
\node[coordinate] (q_2) [left=of q_r, xshift=-3cm, yshift=-1mm] {};
\path[->] % path and draw commands connect the nodes and coordinates to each other.
(q_r) edge [] node {This is an arrow} (q_0);
\draw[->] ([yshift=-3mm]q_1) -- ([yshift=-2mm]q_r.west) node[midway,swap] {This is an arrow};
\draw[->] ([yshift=3mm]q_2) -- ([yshift=2mm]q_r.west) node[midway] {This is an arrow};
\end{tikzpicture}
\end{document}
There are various ways you could do this, but building on what you have.
To place a node halfway along a path, use \draw (a) -- node{..} (b);. Note the placement of the node, just after the --. You can also specify any position along the path, by saying e.g. \draw (a) -- (b) node[pos=<fraction>] {..};, where <fraction> is a number between 0 (start of path) and 1 (end of path).
To change the colour of the node, just add a color in the node options.
I used an arrow tip from the arrows.meta library to draw the black dot in the origin. Saying \draw [<arrow tip>-<arrow tip>] (a) -- (b); will draw a line from a to b with the arrow tip specified by <arrow tip> at each end of the line. Here I used just Circle-, which adds the Circle arrow tip at the beginning of the line, and no arrow tip at the end.
Best Answer
Welcome to TeX.SE!
Here is a simple prototype of what you need. Hopefully, you may apply your desired customizations to it.