1

The EPS format does not support transparency. How can I then include Mathematica graphics that have transparency in LaTeX documents?

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
cyrille.piatecki
  • 4,582
  • 13
  • 26
  • You should like to the mentioned question. At the moment, your question seems very similar, so it may count as a duplicate. – Yves Klett Jun 15 '16 at 09:01
  • I edited the question and answer to read what I think you actually meant. Please review the edit. You can accept your own answer. – Szabolcs Jul 15 '16 at 10:43
  • See my comment to your answer. It appears that the question is talking about plain latex, and not pdflatex. – Jens Jul 15 '16 at 17:45

2 Answers2

3

You can use Rasterize before exporting to a .eps file.

fig = Graphics3D[{Opacity[0.5], Sphere[]}]

enter image description here

Now Export like

Export["fig2.eps", Rasterize[fig]]

which will preserve the opacity in .eps. For better resolution you can use RasterSize.

For comparison

Export["fig1.eps", fig]

Then I use them in a tex file and this is how they look in pdf

enter image description here

Left is without Rasterize (fig1.eps) and right with Rasterize (fig2.eps).

Sumit
  • 15,912
  • 2
  • 31
  • 73
1

LaTeX also supports PDF, not only EPS. Export the graphics in PDF format.

In LaTeX, add \usepackage{graphicx} to the preamble, and include the PDF file using

\includegraphics{file.pdf}

Compile the document using pdflatex. Transparency is preserved.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
cyrille.piatecki
  • 4,582
  • 13
  • 26
  • 2
    This does not seem to be an answer... – Yves Klett Jun 15 '16 at 09:02
  • Why ? I have encounter the problem many time. I have observed that when you save a picture in eps from mathematica the background may be transparent. But if I surimpose say a Triangle with a light opacity, the transparency is not preserved. With my solution it is the case – cyrille.piatecki Jun 15 '16 at 09:10
  • Okay - you should then perhaps add this answer to the thread you mention. The question together with this answer was not clear to me from the start. This answer is more about a TeX implementation... – Yves Klett Jun 15 '16 at 09:17
  • I have tried to add it but as I havbe written in the Ps of the question it was forbiden – cyrille.piatecki Jun 15 '16 at 09:29
  • 3
    This doesn't answer the question. The question was "How do I flatten transparency on a graphics, for conversion to eps or similar?" I think most of us are already aware that (1) PDF supports transparency and (2) PDF can easily be included in LaTeX (neither of which are facts related to Mathematica) But in many cases one is required to use EPS and PDF absolutely isn't an option. Exporting to PDF doesn't flatten transparency. It simply preserves transparency in a format that supports it. There are genuine use cases for actually flattening transparency. – Szabolcs Jun 15 '16 at 09:31
  • I'm saying this because recently the same problem caused me a lot of headache. Some journals only accept EPS, but not PDF. – Szabolcs Jun 15 '16 at 09:35
  • I am not upset by your answer, but Stack exchange is not frequented only by people who master computing – cyrille.piatecki Jun 15 '16 at 09:46
  • 1
    @cyrille.piatecki You could rephrase your question so it asks something that this is an answer for. I'm not saying it's not useful. Such as: How to include Mathematica-generated vector figures in LaTeX documents, or similar. – Szabolcs Jun 15 '16 at 10:59
  • Actually, this isn't quite correct. PDF can be used by pdflatex and newer engines such as lualatex, but not the original plain latex. Your distribution may switch to pdflatex automatically, but strictly it's then no longer plain latex. – Jens Jul 15 '16 at 17:43