Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am interested to use LaTeX like labels in the plots that I prepare in Mathematica, and hence, I downloaded the MathPSfrag package from this website http://wwwth.mpp.mpg.de/members/jgrosse/mathpsfrag/ . Since I cannot attach any file here, I request anyone who is interested to help me, to download the package and run the MathPsfrag-Test.nb notebook. I apologize if the manner in which I am asking the question violates any code of conduct, but since I am new to this group, and because there are multiple files involved with long codes, I am not entirely sure about how else to ask.

This package has been tested only up to version 6, and I am using Mathematica 10 on Windows 7 machine. Unfortunately the package does not work, and I tried finding the problem and any solution to it myself, but without much success. Here is a summary of what I have found.

After unzipping the contents on the package, I followed the instructions and tried running the MathPSfrag-Test.nb notebook line by line. First and foremost I realized that the Windows 7 has a space in their folder names like Program Files, where all programs are installed, and hence, I gave the absolute path to the GhostScript executable, after which the MathPSfragConfigurationTest[] was successful. After that I started executing the notebook step-by-step, and got stuck at the command:

CreatePSfragRules[HandleAutomaticPSfrag[exampleplot]][[1]]

I tried investigating a bit into MathPSfrag.m file, and found the following:

  1. The UtilitiesFilterOptions is replaced by FilterRules in version 10. Hence, I replaced all the commands with FilterOptions functions with the FilterRules function, but with the right syntax.

  2. Despite the above step, I get an error saying that FilterRules function needs two arguments. So I checked the HandleAutomaticPSfrag function defined in the package file, which is defined as HandleAutomaticPSfrag[gr_Graphics,opts___Rule]:= ... and realized that there is a opts___ argument that denotes a BlankNullSequence. The FilterRules as an example is used within this function as as

    FilterRules[opts, Options @ HandleAutomaticPSfrag]
    

    By using the HandleAutomaticPSfrag[exampleplot] command in the Test notebook, there seem to be no opts provided as a second argument, and this is where I think the FilterRules gets stuck.

However, if my explanation of the opts___ above is correct, then I do not understand how the old versions of Mathematica were able to run the package. This makes me feel that I am missing something obvious. Could someone please help me changing the package so that I can also use it with version 10?

Thanks!

share|improve this question
1  
You could instead look at LevelScheme and/or SciDraw –  blochwave Aug 6 at 17:10
    
Thank you Blochwave! I downloaded the packages and skimmed through the user guides. It looks promising, but before I dig into more details of these packages and start using them, could you please tell me if the text formatting of the labels have Computer Modern fonts as used by Latex with the default font encoding, family and series used for the text and Math symbols respectively in LaTeX? –  Ameya Aug 6 at 17:48
    
I'm afraid I don't know, you'll have to check yourself. –  blochwave Aug 6 at 17:51

1 Answer 1

The following was supposed to be a comment, but since I'm new here, I have to put it into an answer.

I used the MathPSfrag package already in Mathematica versions 6, 7, 8 and 9, and everything worked fine (under Windows 7 and 8). Now, with Mathematica 10, the package is indeed no longer working. However, the problem is more serious than just an outdated FilterOptions package, but let me first comment on your question.

The correct way to replace the FilterOptions functionality is the following: Find all appearances of FilterOptions in MathPSfrag (here exemplified by application of FilterOptions to Export) and replace

FilterOptions[Export, opts]

with

Sequence@@FilterRules[{opts},Options@Export].

This solves the problem of wrong number of arguments.

Then there is another issue due to a known bug in the AbsoluteOptions function. At least on my system (Win 8.1, Mathematica 10) Mathematica insists in producing error messages when evaluating AbsoluteOptions, even for harmless examples like AbsoluteOptions[Plot[Sin[x], {x, -2 Pi, 2 Pi}]]. In my case one can safely ignore these error messages. I did this with brute force by simply replacing each appearance of AbsoluteOptions[...,...] with Quiet[AbsoluteOptions[...,...]] in the MathPSfrag file. The same has to be done for the FullGraphics command.

The real problem with Mathematica 10 and MathPSfrag package resides in the fact that EPS files are exported differently (compared to older Mathematica versions), in particalur text labels. Usually, if an EPS file contains a text label this label is stored as cleartext: when opening an EPS (that contains text) with a text editor you can find all text strings in round brackets. MathPSfrag, or more precisely, the LaTeX PSfrag package, searches these strings and replaces them with TeX labels. Unfortunately, for some reason the way of storing EPS files in Mathematica 10 was changed. Text labels do no longer appear as cleartext but rather in an encrypted form, so PSfrag cannot replace them anymore. I suppose the problem is how fonts are embedded. As Verbeia noted in this post the export functionality in Mathematica 10 is now based on the Cairo library.

I'm afraid there's no easy solution to this problem (apart from using older Mathematica versions...), although I know that users of Inkscape encountered related problems but the Inkscape developers seem to have found a workaround in the current version.

Does anyone know if it is possible to change the way of EPS exporting in Mathematica 10?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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