Draw tilted arrow on a diagram using overpic

I have an image in PNG format. I wanted to draw some arrows over it. These arrows are neither horizontal nor vertical. I am facing problem while assigning the directions to vector. Below is the image (in which I have drawn the lines from image editor, just to show)

Below is the code to draw an arrow-

\documentclass{article}
\usepackage[percent]{overpic}
\usepackage{xcolor}

\begin{document}
\begin{overpic}{tube}
\put(36,36){\color{green}\vector(2.5,1){50}}
\end{overpic}
\end{document}


Below is the output-

Notice that .5 is getting printed. I have following questions-

1. How to align arrows in any direction easily?
2. How to draw dotted lines and arrows?
3. How to set thickness of the arrow?
• The argument to \vector should be a pair of integers; with \usepackage{pict2e} the restriction is removed. – egreg Aug 28 '14 at 16:08
• This works fine. Can you tell me (a) How to set the thickness of the arrow? (b) How to draw dotted arrow? – Ravi Joshi Aug 28 '14 at 16:18

The first argument to \vector should be a pair of (coprime) integers. However, the pict2e package removes this restriction and also allows for arbitrary line thickness.

\documentclass{article}
\usepackage[percent]{overpic}
\usepackage{xcolor}
\usepackage{pict2e}

\begin{document}

\begin{overpic}{example-image}
\linethickness{2pt}
\put(36,36){\color{green}\vector(2.5,1){50}}
\end{overpic}

\end{document}


The pict2e package doesn't support dotted arrows.

• Thank you for answering. Please see my updated question. – Ravi Joshi Aug 28 '14 at 16:56

Why not use some thing modern and powerful? Use tikz. You can draw on images.

 \documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{angles}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0,0) {\includegraphics[width=5in]{tube}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
%% next four lines will help you to locate the point needed by forming a grid. comment these four lines in the final picture.↓
\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
\draw[help lines,xstep=.05,ystep=.05] (0,0) grid (1,1);
\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
\foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y};}
%% upto here↑
\begin{scope}[shift={(0.425,0.525)},rotate=-30] %% ←  adjust shift here
\draw[green,ultra thick,-latex] (0,0,0)coordinate[pos=0] (o) -- coordinate (a) (0.30,0,0);
\draw[red,line width=1pt,dotted] (0,0,0) -- coordinate[pos=1] (b)(0,0.30,0);
\draw[blue,line width=2pt,dashed] (0,0,0) -- coordinate[pos=1] (c) (0,0,3);
\draw pic [draw=blue,fill=red,angle radius=5mm] {angle = a--o--c};
\draw pic [draw=green,fill=blue,angle radius=6mm] {angle = a--o--b};
\draw pic [draw=red,fill=green,angle radius=7mm] {angle = c--o--a};
\end{scope}
\node[align=center,text width=4cm, text=red,font=\bfseries] (c) at (0.75,0.75) {Some text here that can run in to many lines};

\end{scope}
\end{tikzpicture}

\end{document}


If you uncomment the lines that draw coordinate system (grids)

%% next four lines will help you to locate the point needed by forming a grid. comment these four lines in the final picture.↓
%\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
%\draw[help lines,xstep=.05,ystep=.05] (0,0) grid (1,1);
%\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
%\foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y};}
%% upto here↑


you get

• By the way, I am a fan of tikz but i was never known this fact about tikz. Thanks a lot. – Ravi Joshi Aug 29 '14 at 9:03
• Can you please tell me (a) how to draw angle (arc) between red line and green arrow using tikz? (b) how to write center align text, which contains multiple lines in tikz? – Ravi Joshi Aug 29 '14 at 9:12
• @RaviJoshi Done. However, what you have asked is very basic in tikz. You may prefer to read the excellent tikz manual (run texdoc pgfmanual from command prompt.) – user11232 Aug 29 '14 at 9:54
• I am getting following error ! Package pgfkeys Error: I do not know the key '/tikz/angle radius', to which you passed '5mm', and I am going to ignore it. Perhaps you misspelled it.See the pgfkeys package documentation for explanation.Type H <return> for immediate help.... ...pic [draw=blue,fill=red,angle radius=5mm]. I am using Texmaker 4.1.1 with MiKTeX 2.9 on a Windows 7 32-bit machine. – Ravi Joshi Aug 29 '14 at 12:50
• @RaviJoshi You need tikz version 3 for using angles library. I doubt that you have version 2.10 or older. Please update using MiKTeX package manager. – user11232 Aug 29 '14 at 14:58