[Tex/LaTex] Replacing labels in EPS file by LaTeX – text not where it should be

psfrag

I am spawning a .eps file with octave by using this .m file:

function dummy
xlim([0 81]);
x = [0:0.01:81];
y=x.^0.5+x.^0.4+x.^0.3+x.^0.2+x.^0.1;
plot (x,y*1.85,"-;aaaa;",'linewidth',2,x,y*1.00,"-;bbbb;",'linewidth',2,x,y*1.25,"-;cccc;",'linewidth',2,x,x/2,"-;dddd;",'linewidth',2);
legend ("location", "northwest");
xlabel ("kkkk");
ylabel ("yyyy");
set (gca (), "xtick",[]);
set (gca (), "ytick",[]);
set (gca (), "fontname","DejaVuSans");
print('-dtex', 'dummy.tex');
endfunction

and including it with this LaTeX "container":

\documentclass[12pt]{article}
\usepackage{psfrag}
\usepackage[dvips]{graphicx,color}
\thispagestyle{empty}

    % You can run this by typing the following commands:
    %    latex 2dplot.tex
    %    dvips -o 2dplot.ps 2dplot.dvi

\begin{document}

% The syntax of the "psfrag" command is:
%    \psfrag{tag}[<posn>][<psposn>][<scale>][<rot>]{replacement}
% See the file pfgguide.ps for full documentation.

\begin{figure}
\psfrag{aaaa}{\small{$y$}}
\psfrag{bbbb}{\small{$s_1 \cdot y$}}
\psfrag{cccc}{\small{$s_2 \cdot y$}}
\psfrag{dddd}{\small{$k(\Sigma + n + g)$}}
\psfrag{kkkk}{\small{$k$}}
\psfrag{yyyy}{\small{$y$}}
\includegraphics{dummy.eps}
\end{figure}


\end{document}

But the psfrag replacements show up at bottom left corner of the page.
Running latex ./dummy.tex does not yield any errors.

Best Answer

The replacements not showing on the actual picture are OK. From the psfrag manual:

When viewing the output with a DVI previewer such as dviwin or xdvi, a vertical list of the replacements will be placed on the left side of each figure. This list allows you to check the typesetting of your replacements; it disappears in the final PostScript version. Unfortunately, DVI drivers are incapable of placing the PSfrag replacements on top of the figure, so for that you will need to print it or use a PostScript previewer like GhostView

You should convert your dvi to ps or pdf or print it in order for the replacements to apply.

Related Question