# How to draw lines on top of an image

I want to make a line which can overlay an image.

I am trying to write a huge command for shortcut a lot of work : New command, load multiple images .

I want to add few lines which can overlay the biggest image in 3rd answer. Tried overpic but it didnt work well.

------ EDIT

This is what I want to achive by modifing this :

\documentclass[draft]{article}

\usepackage{graphicx}
\usepackage{subcaption}

\newcommand{\includegraphicsset}[1]{%
\begin{figure*}
\centering
\begin{subfigure}[b]{\textwidth}
\centering
\includegraphics[width=\textwidth]{/gfx/part#1/pic1}
\caption[short]{the largest picture in the set}
\label{fig:set#1large}
\end{subfigure}
\end{figure*}
}

\begin{document}
\includegraphicsset{1}
\end{document}

• Can you elaborate a bit more on that? Maybe showing an example what you want to achieve? – Johannes_B Jan 8 '15 at 14:21
• This answer, tex.stackexchange.com/questions/171483/…, shows how to use \stackinset to overlay text on an image. You could just as easy make the overlay/inset a \rule, rotated or not. – Steven B. Segletes Jan 8 '15 at 14:22
• @StevenB.Segletes I will look on that. Maybe I will find a way. – jilsu Jan 8 '15 at 14:31
• Using tikz might be a lot easier – daleif Jan 8 '15 at 14:37
• Do you want to give annotations to elements in the picture? Drawing on an image with TikZ – Johannes_B Jan 8 '15 at 15:14

I'm not sure if I've properly understood, but something like this, perhaps?

This uses TikZ with code from Caramdir's answer. The nice thing about that code is that it lets you specify the coordinate relative to the picture so that (0.5,0.5) is at the precise centre, for example.

\documentclass{article}

\usepackage{graphicx,tikz}
\usepackage{subcaption}

\newcommand{\includegraphicsset}[1]{%
\begin{figure*}
\centering
\begin{subfigure}[b]{\textwidth}
\centering
\begin{tikzpicture}% based on https://tex.stackexchange.com/a/9561/ (Caramdir's fantastic answer to another question)
\node (tiger) [anchor=south west, inner sep=0pt] {\includegraphics[width=\textwidth]{tiger}};
\begin{scope}[x={(tiger.south east)},y={(tiger.north west)}]
\foreach \i/\j in {{(0.23,1.05)/(0.25,-.1)},{(0.54,1.1)/(0.5,-.15)},{(0.76,1.05)/(0.8,-0.1)}}
\draw [red, thick] \i -- \j;
\end{scope}
\end{tikzpicture}
\caption[short]{the largest picture in the set}
\label{fig:set#1large}
\end{subfigure}
\end{figure*}
}

\begin{document}
\includegraphicsset{1}
\end{document}


Here is an answer that amplifies my comment about using \stackinset to add lines to images. The OP wasn't very specific on whether there is text attached, etc. This can also be done, but here is the basics of adding lines atop an image.

If multiple lines are to extend beyond the image borders, care must be taken. As each \stackinset of the nest is processed (from the inside out), the "new" vertical image dimension can change. And thus, the location specification must be given with respect to the image dimension from the prior nesting.

So in this MWE, the right most line is the inner \stackinset, and extends .3in below the bottom of the image. The 2nd and 3rd insets are set at a vertical offset of 0in from the bottom of the "revised" image, which means they begin at the same vertical location as the original line. The final inset (the 2nd line from the left), is set at .1in above the bottom of the image, which still leaves it .2in below the original example-image-A.

Note that data extending horizontally from the original image does not change the horizontal dimension of the image. The above referenced remarks apply only to the vertical dimension.

\documentclass{article}
\usepackage{stackengine,graphicx,xcolor}
\begin{document}
{\color{red}
\stackinset{l}{1in}{b}{.1in}{\rotatebox{75}{\rule{3.8in}{1pt}}}{%
\stackinset{l}{.3in}{b}{}{\rotatebox{85}{\rule{4in}{1pt}}}{%
\stackinset{r}{.5in}{b}{}{\rotatebox{-80}{\rule{4in}{1pt}}}{%
\stackinset{r}{1in}{b}{-.3in}{\rotatebox{-85}{\rule{4in}{1pt}}}{%
\includegraphics[width=4in]{example-image-A}%
}}}}}
\end{document}


• I am sorry for lack of specification, I am just tired and forgot about details. Of course lines should extend an image and text should be out of image. But your example is helpful. Maybe I will figure something out. – jilsu Jan 8 '15 at 14:41
• Ok, I will learn and adapt to my case. Thank you for such fast and helful answer. – jilsu Jan 8 '15 at 14:49
• @jilsu Please see revision. – Steven B. Segletes Jan 8 '15 at 14:58