What is the quickest and best way to export a plot image from Mathematica to a $\LaTeX$ Editor? Is there something quicker than exporting it to an image and then including it in the $\LaTeX$ document?
For ease of use when dealing with many different graphics I prepare a notebook for each of these and also generate the LaTeX code for insertion in my document. The graphics get their name from the notebook so you can easily spawn different versions by renaming the notebook.
EDIT: more concise and portable:
The resulting output can be copied as plaintext or you might even splice it directly into your document (although this is a bit much for casual use).
The absolutely fastest way I know to get high-quality
Edit 2: copying complex graphics: 3D plots, contour plots, etc.
As has been noted in this post on $\LaTeX$ and Mathematica, you can no longer rely on
Unfortunately, this means that answers based on
On the other hand, copying as
Fortunately, that can be avoided by making sure that Mathematica automatically rasterizes 3D graphics upon export to
Now all exported and copied
The list of 3D plot functions in the command above can be extended to include some notoriously unwieldy 2D plot functions as well, e.g.,
If you create a notebook with some plots and then save it as LaTeX, not only will the images all be generated but so will LaTeX code that you can use to include those images.
One way to speed up the workflow is to batch process all your images and even formulas if you have many. Basically do all your work in the Mathematica notebook placing distinct graphics, formulas and text in separate cells. Then choose File > Save As... and pick LaTeX Document (*.tex) from the drop down menu of popped up window. This will produce a set of .EPS files for each of your graphics stored in separate cells and a coherent .TEX file with text, formulas and calls to the .EPS images.
The way I do this is by creating a directory structure like the following:
The LaTeX file is in
The notebooks start with
and ends with
The figures are then
The key point is that I export all figures to the correct final size, ensuring that the font sizes will be consistent (e.g. in all figures the fonts will be precisely 8 pt big). (Re-)evaluating the notebook will produce all figures and save them directly into the figure directory.
For the LaTeX part, I use the
If some figures need to be post-processed manually using some illustration software, I export them to a separate directory, then copy the final result manually. I keep all figures under version control (in addition to the figure notebook), in case re-evaluating the figure code will overwrite and break something.
I just figured out the following workaround imitating the psfrag convenience while avoiding intense programming or additional software:
I ended up creating a small version with 212pt Image Size and a larger for full-page plots of 425pt. Also, I made a package to have them ready at every session. This imitates psfrag in the way that if the document font size or -style changes, the plots can be redrawn quickly by simply changing the custom themes and exporting again.
This is not a proper solution to the problem, but an easy workaround, which should be sufficient for most cases. It might not be enough for a journal article, though:
In general it is a shame that Mathematica cannot separate graphics and text upon export. Matlab and most other Software packages have much better latex export functionalities. Maybe it is just a marketing thing - making it hard to avoid the Mathematica style. In any case a much-needed feature for v11!