# How to draw a -latex arrow inside a node

Using the following code, I draw a line and a -latex arrow in 2 different \draw commands. Is it possible to incorporate the -latex code inside the node in the \draw line instead of drawing it in a separate \draw command.

     \documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
{
\begin{tikzpicture}
\draw [thick, green] (1,1) node [red, xshift=.3cm, yshift=0cm] {} -- +(0:2cm);
\draw [thick,blue, xshift=.5cm, yshift=0cm, -latex] (1,1) -- +(0:.5cm);
\end{tikzpicture}
}
\end{frame}
\end{document}


When using the code provided by marmot, only the arrow is shown in a horizontal line but not in a vertical line.What is wrong

     \documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
{
\begin{tikzpicture}
\draw [thick, blue, densely dashed] (1,.8) node [minimum width=2cm, xshift=0cm, yshift=.4cm,path picture={\draw [very thick, solid, red, xshift=0cm, yshift=.2cm, -latex'] (0,0) -- +(90:.8cm);}] {} -- +(90:.9cm);
\draw [thick, blue, densely dashed] (1,.8) node [minimum width=2cm, xshift=.36cm, yshift=0cm,path picture={\draw [very thick, solid, red, xshift=0cm, yshift=0cm, -latex'] (0,0) -- +(0:.6cm);}] {} -- +(0:1.56cm);


\end{tikzpicture} } \end{frame} \end{document}

Yes, with path picture.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{}
{
\begin{tikzpicture}
\draw [thick, green] (1,1) node [minimum width=1cm,red, xshift=.3cm, yshift=0cm,path picture={
\draw [thick,blue, xshift=.5cm, yshift=0cm, -latex] (0,0) -- +(0:.5cm);}] {} -- +(0:2cm);
\end{tikzpicture}
}
\end{frame}
\end{document}


• When applying your code it works with the horizontal line, but not with the vertical line. I included the code in my question. What is wrong – Hany Jun 26 '18 at 14:21
• @Hany You did everything correct except for minimum width, which has to become minimum height in the vertical node. Explanation: nodes come by default with some size, and everything within the path picture that exceeds that size gets cut. That's why I put minimum width in the horizontal node. If you want a universal key, use minimum size=2cm. – marmot Jun 26 '18 at 14:44
• I appreciate very much your effort. You answered my question. – Hany Jun 27 '18 at 4:57