Gray background in export pdf
After a rather long debugging session in our chat we could determine the reason of the problem and come up with a workaround.
In short, we first tried whether the issue appears for the most basic Graphics[]
, which it didn't. As it turned out the gray background is introduced by using PlotLegends
as in the example above. We went further by comparing AbsoluteOptions
of the created graphics and the Options[SwatchLegend]
settings. Everything looked the same on the OP's and my machine.
I then kind of remembered (guessed, whatever) that graphics export is done with the printing style sheet and we tried to set Format => Screen Environment to Printout. This was the first success, because this turned the graphics indeed gray.
Now, we knew the reason, but we couldn't find the exact source. Making a complete diff
between our Core.nb
stylesheet files showed nothing at all. I guess that this setting can be found somewhere else, although the OP stated that this issue persists for over 2 years and has survived even complete operating system changes.
The workaround is as simple as it is intuitive. Open the Preferences and then the Options Inspector and set the PrintingStyleEnvironment to Printout Gray (Is this awesome? It is, isn't it?)
If this issue would appear on my machine, I would probably take a closer look at my
FileNameJoin[{$InstallationDirectory,"SystemFiles","FrontEnd","StyleSheets"}]
directory and grep
through the Default.nb
and the other things to find where this is set. I hope the workaround and the information help someone to track this down.
I recently encountered this problem, and none of the above solutions solved my problems (on version 10.3.1.0). However, I have found a solution which worked for me and should be independant of version.
On my version, the problem specifically occurred when using the Report
stylesheet, but vanished with the Default
one. The trick was to make a custom stylesheet that includes all of the style definitions from Report
except the offending Graphics
cell definition.
To achieve this practically, I switched to the Default
stylesheet on the target notebook, opened a new mathematica notebook with a Report
stylesheet , went to Format > Edit stylesheet on both and clicked Report/StandardReport.nb
on the latter to load the Report's default cell definitions. Then I copied all the Report's cell definitions over to the Private Style Definitions for XXX.nb notebook and then went in and removed the offending local definition for graphics in Styles for Input and Output Cells
as well as changing the background color for Output
to white (select the cell then Format > Background Color > White).
Graphics now have a white background for both the image and text labels (an issue raised in another StackMMA question).
This new stylesheet can then be saved Default by following these instructions.