# How can I add or overlay a legend to an .eps image

Assume someone has several Matlab plots saved as .eps graphics and realizes in some of them the legend for the curves is missing.
Is there a way to add these legends afterwards, or to overlay another .eps graphic that contains just the legend box? The .eps graphics are included like

\begin{figure}[htb]
\centering
\includegraphics[width=0.7\textwidth]{path/to/eps}
\cprotect\caption{gibberish.}
\label{fig:fug}
\end{figure}


A solution using as little 'non-standard' libraries as possible would be favored.

• – user2478 May 7 '13 at 10:50
• The overpic package may be what you need; see How to superimpose LaTeX on a picture. Don't use \cprotect except when it's really needed: it isn't in a normal figure environment. – egreg May 7 '13 at 11:11
• Nice to know and thanks for the link. I really do need \cprotect because I have a \verb|| expression in the caption. – damage May 7 '13 at 11:32

With PSTricks.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{graphicx}

\def\filename{fist-of-legend}
\def\row{10}
\def\column{10}
\def\scale{1}

\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=\scale]{\filename}}
\psset
{
xunit=\dimexpr\wd\IBox/\column,
yunit=\dimexpr\ht\IBox/\row,
}

\begin{document}
\begin{pspicture}[showgrid=top](\column,\row)% set showgrid=false for the final
\rput[bl](0,0){\usebox\IBox}
\rput(7,1.25){\psscalebox{3}{\bf\color{white}PSTricks}}
\end{pspicture}
\end{document}


## Remarks:

1. Compile it with either latex-dvips-ps2pdf sequence (much faster) or xelatex (much slower).
2. Toggle the showgrid with true, false, top, or bottom. true is identical to bottom. The grid is useful to find the coordinate.