3

UPDATE:I tried the solution with overpic and it works fine. But the problem is, sometimes, my experimental setup changes and I have to reproduce the eps file using different parameters from Matlab. This results in me again re-adjusting the co-ordinates to align the tex code corresponding to the different objects in the image(eps format). This is difficult when I have to do it often. Is there any solution for that?

QUES: I have an image of solid rectangle generated in eps format from Matlab. Let us say, there is no other way for me to generate the same (I have other complicated things inside this rectangle). I want to mark the co-ordinates of the corners of this rectangle. Thus, I want to insert some text of the form

$(\lambda_{min},\lambda_{max})$

inside the image. The inbuilt editor of Matlab is not satisfactory. Is there any option in LaTeX to do the same?

1

3 Answers 3

2

PSfrag is a LaTeX package that allows one to overlay Encapsulated PostScript ( EPS) figures with arbitrary LaTeX constructions. I know that it works for figure created with MATLAB but I forgot if there are any caveats. I very seldom use MATLAB to create pictures for my documents. I use PSfrag often with Xfig. It is included in most TeX distribution with exception of KerTeX.

1
  • it is useful!. I am waiting for other replies. May 15, 2013 at 5:15
2

It is very easy problem. Overlaying a text on the existing EPS can be done as follows.

  • Create a new input file just for overlaying the existing EPS. Use standalone document class so we get a tight output (all white spaces outside are trimmed automatically). The following code snippet can be used as a template. The border key should be removed in the final stage.

  • You need to change the \filename and \scale (if necessary).

  • Specify the coordinate at which you want to put the label.

  • Compile this input file with either latex-dvips-ps2pdf (much much faster) or xelatex (much slower) to get a tight PDF output.

  • Import the PDF output from within your main input file by using \includgraphics and compile this main input file with pdflatex.

  • Done!

enter image description here

\documentclass[pstricks,border=12pt]{standalone}% remove border key in the final stage.
\usepackage{graphicx}

\def\filename{example-image-a}% change it to your filename
\def\scale{1}
\def\row{10}
\def\column{10}

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

\begin{document}
\begin{pspicture}(\column,\row)
    \rput[bl](0,0){\usebox\IBox}
    \psgrid% turn this grid off in the final stage.
    \rput(5,8){\color{red}\Huge$(\lambda_{min},\lambda_{max})$}
\end{pspicture}
\end{document}
3
  • Is the same possible in tikz? May 15, 2013 at 8:26
  • @dineshdileep: No for EPS. May 15, 2013 at 14:16
  • +1, really appreciate the effort, but not so useful for me. May 17, 2013 at 5:31
1

Using overpic, assuming there is no tagged eps file to use with psfrag. overpic relative example at ctan.

Place the math labels at target locations with the help of overlay grid. Once math labels are set disable the grid similar to PSTricks answer.

enter image description here

\documentclass{article}
\usepackage[percent]{overpic}
\begin{document}
%\begin{overpic}[width=\linewidth,grid,tics=10]{sphere-example}
% sphere generated from matlab % sphere; cpmmand
\begin{overpic}[width=\linewidth]{sphere-example}
\put(0,15){\Large$\lambda_{max}$}
\put(40,-3){\Large$\lambda_{min}$}
\put(50,-3){\Large$\lambda_{min}$}
\put(98,10){\Large$\lambda_{max}$}
\end{overpic}
\end{document}

The psfrag package replaces text strings (eg: x,y or tags) in tagged eps files. It is advisable to generate tagged .eps with tags( small labels) at appropriate location so as to replace them with psfrag. Refer the Guide to using Encapsulated PostScript in LATEX for more psfrag.

Related Question: How to superimpose LaTeX on a picture?

4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .