How to draw images in Latex?

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}  

enter image description here


For complicated figures with graphics, I think there is some consensus that tikz is the way to go. It is probably worth learning. It is amazing, but can be intimidating for the beginner. For very simple pictures (lines, arrows, text, ovals) the picture environment has easy-to-learn tools. The \put command together with \line and \vector commands can recreate your picture.

The basic idea is to \put the objects at coordinates relative to the current baseline position. The downside is that small adjustments require recalculating all your coordinates. Lengths and coordinates are in terms of \unitlength.

For \line and \vector commands the format is

\line(∆x,∆y){length}

The ∆x and ∆y arguments specify the slope (and direction) for lines (and vectors).

Here is the code for an approximation of your picture:

\documentclass{article}

\begin{document}

\noindent I am trying to draw something like this:

\bigskip
\begin{picture}(240,50) % set dimensions of the picture
\put(10,10){\vector(1,0){100}} % lower arrow
\put(30,1){\scriptsize This is an arrow}
\put(10,40){\vector(1,0){100}} % upper arrow
\put(30,44){\scriptsize This is an arrow}
\put(110,0){\line(1,0){120}} % these 4 lines make a rectangle
\put(230,0){\line(0,1){50}}
\put(110,0){\line(0,1){50}}
\put(110,50){\line(1,0){120}}
\put(230,25){\vector(1,0){100}} % right arrow
\put(250,29){\scriptsize This is an arrow}
\put(142,30){\Large \sffamily This is a}
\put(150,10){\Large \sffamily square}
\end{picture}

\bigskip
\noindent More text.

\end{document}

enter image description here


for joy (exploiting answer of Roboticist as "your" mwe):

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta, positioning, quotes}% used tikz libraries

\begin{document}
    \begin{tikzpicture}[
    auto,                            % positioning of edges labels
    node distance = 2.5 mm and 40mm, % vertical and horizontal distances between node/coordinates
       box/.style = {rectangle, draw, align=center}% style of node
                        ]
    \node (n1) [box]    {This is\\ a square}; % node with style "box"
    % used coordinates 
    \coordinate[above left=of n1.west]  (in1); 
    \coordinate[below left=of n1.west]  (in2);
    \coordinate[right=of n1.east]       (out);
    arrows
    \draw[-Straight Barb]   % arrows head determined by arrows.meta
        (in1) edge ["This is an arrow"  ] (in1 -| n1.west)
        (in2) edge ["This is an arrow" '] (in2 -| n1.west)% ' means "swap" edge label on another side of adge
        (n1.east) to ["This is an arrow"  ] (out);
    \end{tikzpicture}
\end{document} 

code should be self-explanatory ... now i add comments, which describe meaning of using of some code lines. of course, for mastering of tikz it is good to read tikz & pgf manual ..., at least introduction parts (1. tutorial) and then TikZ ist kein Zeichenprogramm.

enter image description here

Tags:

Draw