1

I am trying to use psfrag to alter axes labels of plots from Mathematica. Unfortunately eps files are not supported by pdflatex, so they are converted using epstopdf. To get the epstopdf working, I altered the initialisation file of pdflatex to enable write18 following the instructions of this post, it works fine now.

Now to get psfrag working together with epstopdf, I included auto-pst-pdf. So my includes look like:

\usepackage{graphicx, psfrag}
\usepackage[outdir=./]{epstopdf}
\usepackage{auto-pst-pdf}

My Latex file compiles without any errors, the log files are empty. But maybe I should mention that I use \graphicspath{{img/}} to alter the standard graphics path.

The Latex code I use to include my figures goes something like this:

\begin{figure}
    \psfrag{xlabel}{Frequency}
    \psfrag{ylabel}{Acceleration}
    \includegraphics{somefigure.eps}
\end{figure}

I am using MikTeX and edit the files with TeXworks. What am I doing wrong?

EDIT: I didn't know that I wasn't providing enough information about my problem, so here is the test file I set up, along with the test eps file:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{psfrag}
%\usepackage{auto-pst-pdf}

\begin{document}

\begin{figure}
    \psfrag{xlabel}{Frequency ($Hz$)}
    \psfrag{ylabel}{Acceleration ($\frac{m}{s^2}$)}
    \includegraphics{testfigure.eps} 
\caption{Test}
\end{figure}

\end{document}

Here is the Google Drive Link to my eps file.

All files are in the same directory, I don't get any errors or warnings.

EDIT2: Like Ulrike Fischer suggested, I now ran the test document with pdflatex and included auto-pst-pdf this time. Here are the results:

The only errors in the log files I found were these from TeXworks itself (in the logfile with the name "texworks", all other log files were either empty or had old logs in it.):

2017-03-27 14:08:04,220+0200 INFO  texworks - starting: MiKTeX TeXworks 0.6.1 (MiKTeX 2.9.6210 64-bit)
2017-03-27 14:08:04,220+0200 INFO  texworks -   argument(s): C:\Users\########\Google Drive\Uni\Grenoble\Bachelorarbeit\LIVE\test.tex

The errors I get in TeXworks are:

pdflatex+auto-pst-pdf produces these errors

So there is obviously something wrong with epstopdf, but why?

EDIT3: Ulrike Fischer suggested copying the test file to a local folder (or a folder not watched by Google Drive) and trying running pdflatex --shell-escape test in a shell. Now I get proper help from the errors thrown:

Package pst-pdf Warning: File `test-pics.pdf' not found.
(pst-pdf)                Use the following commands to create it:
(pst-pdf)                ----------------------------------------------------
(pst-pdf)                latex test.tex
(pst-pdf)                dvips -o test-pics.ps test.dvi
(pst-pdf)                ps2pdf test-pics.ps
(pst-pdf)                ----------------------------------------------------

Using first latex and then dvips followed by converting the post script file into a pdf works. I can write a script that automates this, but isn't there a more easy fix? And I don't know enough about LaTeX to know that this won't mess with any of my packages I now use?

NE555
  • 11
  • there are several ways psfrag can fail first try just using latex+dvips instead of pdflatex (actually if that works you are done as you can save the result as pdf and include it into the pdflatex document) (although I don't think you should load the epstopdf package explictly, let auto-pst-pdf handle it) – David Carlisle Mar 25 '17 at 21:25
  • So I have to install a new Latex editor/shell for that purpose? If I don't load the epstopdf explicitly, then I get an error when setting the image path... – NE555 Mar 25 '17 at 21:40
  • no, miktex includes latex and pdflatex you don't need to install anything you haven't got already also start from the simplest configuration, the image in the same folder as the document so no graphics path and no specified output directory – David Carlisle Mar 25 '17 at 21:46
  • Why do you complicate your setup by using a graphicspath and a output-dir and auto-pst-pdf? Try first a simple example and when this works you can think about refinements. Beside this: when you get errors you should tell the error message. – Ulrike Fischer Mar 25 '17 at 22:05
  • Ok I set up a test document, but now things get weird: I am compiling just with pdflatex, and with all the same inlcudes and the same code, now I get the problem that write18 isn't enabled (which is enabled in the ini file). So I added a shell option to the compiler settings in TeXworks, to both the pdfLatex+MakeIndex+BibTeX compiler and the pdfLatex compiler. The original file compiles as usual without errors, the pdfLaTeX compiler says that the shell option isn't recognized?! – NE555 Mar 25 '17 at 22:11
  • I simplified it further and kicked out every package, except for graphicx and psfrag. When I compile with just pdflatex, no errors are generated and my eps file is included, but psfrag does not replace the tags. – NE555 Mar 25 '17 at 22:14
  • psfrag needs latex +dvips. Beside this: how should we be able to help you if you don't show your document and the eps? – Ulrike Fischer Mar 25 '17 at 22:20
  • @UlrikeFischer Ok, sorry I didn't know my info wasn't sufficent. I followed this post on Google Groups, that's were the auto-pst-pdf comes from. – NE555 Mar 26 '17 at 13:28
  • Your example works fine for me with a current miktex. With both ways latex + dvips +ps2pdf without auto-pst-pdf and pdflatex --shell-escape with auto-pst-pdf the labels are replaced. Assuming that you want to use pdflatex: activate auto-pst-pdf, compile with pdflatex and then show the resulting log-file. – Ulrike Fischer Mar 26 '17 at 13:52
  • @UlrikeFischer I have added the additional info now. I read that epstopdf should load automatically, but it looks like it doesn't here. Also I fear that I did something wrong enabling write18, but I can't see what: I edited the pdflatex.ini and added this line: EnableWrite18=t. I also tried adding --tex-option=--shell-escape in the Tool Configuration in TeXworks. – NE555 Mar 27 '17 at 12:30
  • Undo your changes of some ini-files. Close texworks. Copy your files from you google driver to some local folder. Learn on the internet how to open a command line in this local folder and then run there pdflatex --shell-escape test. Then you will hopefully get a sensible log-file. – Ulrike Fischer Mar 27 '17 at 12:36
  • @UlrikeFischer Thank you so much for your help! I got it working and my edit to the ini file also works. I have also tested it in the Drive and it also works there. But is there now a way to make it work in TeXworks with pdflatex? – NE555 Mar 27 '17 at 12:57
  • Given your use case, I recommend that you use my MaTeX package to label your figures in Mathematica. The bundled documentation discusses in detail how to match style between LateX and Mathematica. – Szabolcs Mar 29 '17 at 12:04
  • @Szabolcs Thank you for sharing this! This may be my solution! :) – NE555 Apr 04 '17 at 06:55
  • @NE555 If you found it helpful, perhaps it's useful to have an ad for it here on TeX.SE. Your vote here will be appreciated. – Szabolcs Apr 04 '17 at 12:28

0 Answers0