Skip to main content

graphics - How can I insert an EPS file exported from RegionPlot into MS Word?


I generate a figure using RegionPlot and then Export it as "EPS". When I insert this picture into MS Word, it doesn't work.


The figure is generated by the following code:


Constraint1[α1_, α2_] := Cos[α2] (Sin[α2]/Sin[α1] - Sin[α2] Cot[α1] + Cos[α2]);

CSSSS = Show[

RegionPlot[
0 < α1 < α2 < 60 && Constraint1[α1*π/180, α2*π/180] > 1/2,
{α1, 0, 59.999}, {α2, 0, 60},
BaseStyle -> {FontFamily -> Times, 25}, ImageSize -> 600,
FrameLabel -> {Style["\!\(\*SubscriptBox[\(α\), \(1\)]\)(\[Degree])", 28],
Style["\!\(\*SubscriptBox[\(α\), \(2\)]\)(\[Degree])", 28]},
PlotLabel -> Style["Value Range of Basic Angles", 25, Black],
FrameStyle -> Directive[Thickness[0.003], Black],
Epilog -> {Inset[Style["(45, 60)", 25], {40, 59}],
Inset[Style["(45, 50)", 25], {50, 49}],

Inset[Style["(40, 50)", 25], {35, 49}]}],
ListPlot[{{45, 60}, {45, 50}, {40, 50}}, PlotStyle -> Red]]

Export["xxx.eps", CSSSS]

Screenshot after importing the "xxx.eps" file into MS Word:



screenshot




Answer




The figure you are trying to Export into EPS format contains semi-transparent objects unsupported by this format:


Cases[CSSSS, _Opacity, Infinity]


{Opacity[0.3]}

Actually all the filling produced by RegionPlot is semi-transparent as you can easily find using my shortInputForm function:


CSSSS // shortInputForm

Since transparency actually isn't necessary for your image you can simply replace default semi-transparent filling with non-transparent color (which exactly reproduces the default styling) by adding the following option to RegionPlot:



PlotStyle -> RGBColor[0.8105251`, 0.8520337`, 0.9129394`]

Now


Cases[CSSSS, _Opacity, Infinity]


{Opacity[1]}

while the plot looks exactly as it was looking originally.


In the general case when you have semi-transparent objects overlapping with some non-uniform background you have to perform transparency flattening, see this answer for details.



However even after removing transparency MS Word still cannot import the EPS file Exported from Mathematica 10.2 (which I currently work with, but the same is true for version 8.0.4). The most probable reason is that this EPS file contains PostScript Level 3 instructions which MS Office EPS Import Filter cannot understand. In this answer I discuss limitations of the latter and known methods allowing to generate EPS files compatible with MS Office. The most reliable way is to Export as PDF from Mathematica, then use free utility pdftops or pdftocairo from Poppler utilities for Windows for generating Level 2 EPS file as follows:


pdftops -level2 -eps input.pdf
pdftocairo -level2 -eps input.pdf

Following the pdftocairo route I obtain EPS file which MS Word 2003 successfully imports producing the following visual appearance in Word:


screenshot


As you can see, the Greek letters α are not displayed and instead of Times it displays all text as Arial. But what you see is not the actual imported figure: it is just a preview automatically generated by MS Office EPS Import filter which is known to be inaccurate. For the purposes of printing to PostScript printers this preview isn't used by Word: it sends original PostScript code to the PostScript printers (this code is embedded into Word document when you import a EPS file but cannot be displayed because Word cannot render PostScript). The preview is used only for display purposes and for printing to non-PostScript printers. Let us try to print this Word document to the "Adobe PDF" virtual printer and check how generated PDF file looks in Adobe Acrobat:


screenshot


The figure looks perfectly and the glyph α is correctly embedded!





If you are not satisfied with the above result you have to go through the Adobe Illustrator route described in the linked answer: import the PDF file Exported from Mathematica into Illustrator, edit it in order to fix incorrectly imported text, then export as EPS with unchecked option "Include CMYK PostScript in RGB Files". From my experience, EPS files exported from Illustrator this way are always previewed correctly in MS Word.


Comments

Popular posts from this blog

functions - Get leading series expansion term?

Given a function f[x] , I would like to have a function leadingSeries that returns just the leading term in the series around x=0 . For example: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x)] x and leadingSeries[(1/x + 2 + (1 - 1/x^3)/4)/(4 + x)] -(1/(16 x^3)) Is there such a function in Mathematica? Or maybe one can implement it efficiently? EDIT I finally went with the following implementation, based on Carl Woll 's answer: lds[ex_,x_]:=( (ex/.x->(x+O[x]^2))/.SeriesData[U_,Z_,L_List,Mi_,Ma_,De_]:>SeriesData[U,Z,{L[[1]]},Mi,Mi+1,De]//Quiet//Normal) The advantage is, that this one also properly works with functions whose leading term is a constant: lds[Exp[x],x] 1 Answer Update 1 Updated to eliminate SeriesData and to not return additional terms Perhaps you could use: leadingSeries[expr_, x_] := Normal[expr /. x->(x+O[x]^2) /. a_List :> Take[a, 1]] Then for your examples: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x), x] leadingSeries[Exp[x], x] leadingSeries[(1/x + 2 + (1 - 1/x...

How to thread a list

I have data in format data = {{a1, a2}, {b1, b2}, {c1, c2}, {d1, d2}} Tableform: I want to thread it to : tdata = {{{a1, b1}, {a2, b2}}, {{a1, c1}, {a2, c2}}, {{a1, d1}, {a2, d2}}} Tableform: And I would like to do better then pseudofunction[n_] := Transpose[{data2[[1]], data2[[n]]}]; SetAttributes[pseudofunction, Listable]; Range[2, 4] // pseudofunction Here is my benchmark data, where data3 is normal sample of real data. data3 = Drop[ExcelWorkBook[[Column1 ;; Column4]], None, 1]; data2 = {a #, b #, c #, d #} & /@ Range[1, 10^5]; data = RandomReal[{0, 1}, {10^6, 4}]; Here is my benchmark code kptnw[list_] := Transpose[{Table[First@#, {Length@# - 1}], Rest@#}, {3, 1, 2}] &@list kptnw2[list_] := Transpose[{ConstantArray[First@#, Length@# - 1], Rest@#}, {3, 1, 2}] &@list OleksandrR[list_] := Flatten[Outer[List, List@First[list], Rest[list], 1], {{2}, {1, 4}}] paradox2[list_] := Partition[Riffle[list[[1]], #], 2] & /@ Drop[list, 1] RM[list_] := FoldList[Transpose[{First@li...

front end - keyboard shortcut to invoke Insert new matrix

I frequently need to type in some matrices, and the menu command Insert > Table/Matrix > New... allows matrices with lines drawn between columns and rows, which is very helpful. I would like to make a keyboard shortcut for it, but cannot find the relevant frontend token command (4209405) for it. Since the FullForm[] and InputForm[] of matrices with lines drawn between rows and columns is the same as those without lines, it's hard to do this via 3rd party system-wide text expanders (e.g. autohotkey or atext on mac). How does one assign a keyboard shortcut for the menu item Insert > Table/Matrix > New... , preferably using only mathematica? Thanks! Answer In the MenuSetup.tr (for linux located in the $InstallationDirectory/SystemFiles/FrontEnd/TextResources/X/ directory), I changed the line MenuItem["&New...", "CreateGridBoxDialog"] to read MenuItem["&New...", "CreateGridBoxDialog", MenuKey["m", Modifiers-...