I want to draw arrows horizontally or vertically beside to rectangle. How may I code for it in overleaf code? with tikz package or else
\begin{tikzpicture}
\draw[black, thick] (0,0) rectangle (3,2) node[pos=.5] {text};
\end{tikzpicture}
I want to draw arrows horizontally or vertically beside to rectangle. How may I code for it in overleaf code? with tikz package or else
\begin{tikzpicture}
\draw[black, thick] (0,0) rectangle (3,2) node[pos=.5] {text};
\end{tikzpicture}
@marmot has proposed a nice approach in the comment. Here I use another way, which is based on coordinates.
\documentclass[tikz]{standalone}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
\draw[black, thick] (0,0) rectangle (3,2) node[pos=.5] {text};
\draw[stealth-stealth] (-.2,0) -- (-.2,2) node[midway,above,sloped] {\SI{2}{cm}};
\draw[stealth-stealth] (0,2.2) -- (3,2.2) node[midway,above] {\SI{3}{cm}};
\end{tikzpicture}
\end{document}
\documentclass[border=3.14mm,tikz]{standalone} \begin{document} \begin{tikzpicture} \node[minimum width=3cm,minimum height=2cm,draw,thick](n) {text}; \draw[-latex,thick] (n.east) -- ++ (2,0); \draw[-latex,thick] (n.north) -- ++ (0,2); \end{tikzpicture} \end{document}– Mar 28 '19 at 18:22overlaypicture). If you have more stuff in thetikzpicture, you can say\node[minimum width=3cm,minimum height=2cm,draw,thick](n) at (1.5,1) {text};. However a great feature of tikz is relative positioning, so in many situations you do not need to use explicit coordinates but rather load thepositioninglibrary and put the nodes relative to each other. – Mar 28 '19 at 18:36