5

I'm picking up a document, thus far, created by someone else who is unavailable for questioning.

I have a vague idea what is trying to be accomplished with this:

\clearpage
\begin{figure}[h!]
\psfrag{F}{$F_c$}
\psfrag{M}{$M_0$}
\psfrag{V}{$V$}
\psfrag{Y}{$Y$}
\psfrag{X}{$X$}
\psfrag{T}{Thin film}
\psfrag{A}{Adhesive layer}
\psfrag{R}{Rigid surface}
\includegraphics{figure1a}
\end{figure}

(there are 2 more figures, b and c then)

"Fig. 1 Schematic description....." for a bottom of the page caption.

I can latex it without error, but when I try to pdfltex ... it I get an error message that states:

I could not locate the file with any of the extensions: .png, .pdf, .jpg, .mps, .jpg, .jbig2, .jb, .PNG, .PDF, .JPG, .JPEG, .JBIG2, .JB2 Try typing <return> to proceed.

After latex, xdvi file displays the desired figure, but there is text scrunched up on the left of the page, to the left of the figure partially revealing "F_c" (in the proper format) through X on successive lines, then "Thin film, Adhesive layer", then "Rigid surface". To the right of the figure is the figures' designator letter (a).

Just above to figure in the left margin above "F_c" is a cut-off word, ending ing 'g', I think "g replacements".

When I pdflatex in order to create a PDF file, then getting the aforementioned error message, I just , through it. The resulting PDF is a blank page, save for the figures' letter designators, (a), (b), and (c) in a column down the center of the page with the "Fig.1..." caption at the bottom of the page.

The figure1a is in the same directory as the document files as figure1a.fig in addition to a figure1a.eps.

I've been able to come up with scant little help in the Leslie Lamport book.

Can you tell me what the psfrag business is all about?

I've imported figures in my own documents, but not in this fashion. I hate to re-tool this one if I can create something better and learn a new technique in the process.

  • One issue here is that pdflatex can't handle eps files straightforwardly. It is looking for any of the listed file types. Convert the eps to a pdf first and try again. – Markus Oct 30 '14 at 14:05
  • 3
    See for example tex.stackexchange.com/questions/11839/…: you need to set up to run latex for the figures and then convert the appropriate parts to PDF format for pdflatex. That's best done using some automation. – Joseph Wright Oct 30 '14 at 14:06
  • So... adding \usepackage[pdf]{pstricks} to the preamble will fix it? (I'm kind of new to LaTeX) also, should I post commentary here or on the linked page? – TommyK Oct 30 '14 at 14:43
  • @TommyK as Joseph pointed out, psfrag is intended to be used along the latex route. Not sure if the [pdf] workaround has any effect on psfrag – Markus Oct 30 '14 at 14:48
  • So, I added the \usepackage[pdf]{pstricks} to no avail. I'm still confused. – TommyK Oct 30 '14 at 16:38
5

The psfrag package is used to remove labels and other text from .eps graphics and replace them with LaTeX labels. This can be used to ensure that fonts in figures are consistent with those in the main body of the document, regardless of whether your graphics software can access them. It is particularly useful for inserting formulae and symbols, since a label in the eps file can be replaced by (more or less) arbitrary LaTeX code. In this example, the word 'typography' is replaced by an italic version in the current font.

\documentclass{article}
\usepackage{graphicx}
\usepackage{psfrag}
\begin{document}
\begin{center}
\includegraphics[width=70pt]{small}
\end{center}
\begin{center}
\psfrag{typography}{\textit{typography}}
\includegraphics[width=70pt]{small}
\end{center}
\end{document}

The file 'small.eps' is as follows:

%!PS-Adobe-2.0 EPSF-2.0
%%Title: test.eps
%%BoundingBox: 0 0 100 50
/Times-Roman findfont
15 scalefont
setfont
20 20 moveto
(typography) show
showpage
%EOF

frag

However, as you have discovered, psfrag only works if you compile via latex -> dvips -> ps2pdf; it won't work with pdflatex. There is a package called pstool which works around this problem. Provided that shell escape is enabled, this version of the example will work with pdflatex.

\documentclass{article}
\usepackage{pstool}
\begin{document}
\begin{center}
\includegraphics[width=70pt]{small.eps}
\end{center}
\begin{center}
\psfragfig*[width=70pt]{small}{\psfrag{typography}{\textit{typography}}}
\end{center}
\end{document}
  • 2
    For pdflatex one can also load psfrag and auto-pst-pdf and use psfrag's original syntax. (This also requires shell-escape to be enabled.) – clemens Oct 31 '14 at 17:13
1

To use psfrag with pdflatex, the first things is to make

pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex

In pdflatex compelation (--shell-escape %.tex)

And after you should be load auto-pst-pdf and psfrag

\documentclass[border={0pt 5pt 0pt 0pt}]{standalone}
\usepackage{graphicx}
\usepackage{psfrag}
\usepackage{auto-pst-pdf} 
\usepackage{psfrag}
\begin{document}
\begin{psfrags}
    \psfrag{G}{0.2}
    \psfrag{H}{0.15}
    \includegraphics[width=15cm,height=12cm]{aeee.eps}
\end{psfrags}
\end{document}

with my best wishes Abdelkarim

0

Update: In my work environment we are using WinaXe xserver application to view .dvi files. Within the xserver application is a command File> Save As>... One can then change the file type to PDF, then click SAVE. This generates a bonafide .pdf file which displays and prints the labels as expected.

Easy Peasey Lemon Squeezy.

Jeepers, I wish my predecessor would have left some documentation!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.