Message Boards Message Boards

psfrag for Mathematica 10

Posted 9 years ago

Hello,

As far as I understand, psfrag is no longer working with Mathematica 10. Does anyone have a solution for this problem or knows whether there will be a solution in the near future? Or is there an alternative? What I want to do is export eps files from Mathematica and include them into Latex with nice Labels.

POSTED BY: a b
11 Replies
Posted 5 years ago

Really, Szabolcs has made an good enough p.C.. Regardless, it does not handle my fear with psfrag-substitutions using eps-pictures in a LaTeX-document.

POSTED BY: Luigi Vann
Posted 5 years ago

Mathematica often produces corrupted EPS files, hence is is usually better to Export your graphics as PDF, then convert the latter to EPS using third-party tools. Here are some posts of mine containing description of different ways to do this:

POSTED BY: Alexey Popkov
Posted 5 years ago

Thanks for the interesting suggestion, Alexey. I am unable to tell for sure, but it may well be that flattening transparency is related to my problem. The images were Graphics objects, not Graphics3D.

I am not sure that I can use your method. I don't know how LaTeX does it, but it needs to be able to identify certain strings of text in the EPS-file as such for the psfrag-substitution to work the way it used to (substitute a user specified string with a TeX-command). The rest of my document will be typeset by LaTeX, and using fonts other than those in my TeX-system is not an option.

My testing confirmed that Mathematica was changed for worse in this sense when moving away from version 9. I would also like to know why Wolfram did that? Or is there an export option to go back to this (not unlike the option to temporarily go back to version 5 graphics that existed in some versions for the purposes of backwards compatibility)?

POSTED BY: Jyrki Lahtonen

There is a dedicated thread on this forum by Szabolcs: LaTeX typesetting in Mathematica

POSTED BY: Vitaliy Kaurov
Posted 6 years ago

Yes, Szabolcs has made a nice package. But it does not solve my problem with psfrag-substitutions using eps-images in a LaTeX-document.

POSTED BY: Jyrki Lahtonen

Could you please explain what you can achieve with psfrag (or MathPSFrag) that is not possible with MaTeX? Maybe there is a way to improve MaTeX to accommodate your use case. I would simply like to understand your motivation for wanting to use psfrag.

POSTED BY: Szabolcs Horvát
Posted 5 years ago

Thanks for this, Szabolcs!

As I "promised" in stackexchange I got around to testing MaTeX now that I'm updating my lecture notes. Works very well for me. Particularly in 3D eps-images where I never got good results with LaTeX's psfrag-package. A thing I am missing from psfrag is that the font size is no longer determined at complie time - no way MaTeX could know how I will rescale the image afterwards :-( Then again, psfrag substitution occasionally produces uncomfortably large symbols for the chosen image size. So I am inclined to call this a feature as opposed to a bug. After all, MaTeX will let me specify the fontsize anyway.

Thanks once more. Happy with MaTeX!

POSTED BY: Jyrki Lahtonen

A thing I am missing from psfrag is that the font size is no longer determined at complie time - no way MaTeX could know how I will rescale the image afterwards

This is a very good point. So many people get this wrong when creating figures—they don't think about the final size of the image, and the fonts won't match the surrounding text after rescaling.

The MaTeX documentation includes a tutorial on how to deal with this. There are no magic solutions, unfortunately. It simply gives suggestions on how to plan ahead and consider the target figure size from the beginning, and how to use scaling and non-scaling units in Mathematica. (Note that all of them will scale once you've exported to PDF—but not when resizing within Mathematica.)

It's actually useful to plan ahead even if the font size could be determined at LaTeX-compile-time. It's not just the font sizes that should ideally not scale, but also some other features like point sizes and line widths. E.g., it's hard to judge the colour of a line if it's too thin. I like to specify line widths in absolute units (i.e. non-scaling units) for this reason.

POSTED BY: Szabolcs Horvát

By the way, am I the only one having trouble with the size of exported pdf from a Row[] object? For example:

dsk = Graphics[{Circle[], Text["abc"]}, ImageSize -> 250]
Export[NotebookDirectory[] <> "dsk.pdf", dsk]
twoDsks = Row[{dsk, dsk}]
Export[NotebookDirectory[] <> "twodsks.pdf", twoDsks]

In the notebook the second picture is twice as wide as the first, but the exported pdf's are not in the same proportion. This is annoying when planning for a precise point size.

POSTED BY: Gianluca Gorni
Posted 9 years ago

Thank you very much. This is awesome.

POSTED BY: a b
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract