4
$\begingroup$

Sometimes I need Notebook-specific options such as Background color or FontProperties -> "ScreenResolution". (Ref: How to set default magnification for all windows.)

This works just fine in most ways, except that when I use any of:

the Global value is used rather than the Notebook value, and the image is very different.

Here is a self-contained example:

SetOptions[$FrontEndSession,
  {Background -> None, 
   FontProperties -> {"ScreenResolution" -> 96}}];

SetOptions[EvaluationNotebook[],
  {Background -> LightBlue, 
   FontProperties -> {"ScreenResolution" -> 72}}];

Plot[Sinc[x], {x, 0, 10},
 Epilog -> Text[Style[Sinc[x], 16], {5.5, 1/2}], 
 ImageSize -> Small
]

Rasterize[%]

enter image description here

Is there some way to make these export methods use the Notebook options?

(I am especially concerned with the FontProperties -> "ScreenResolution" value.)

$\endgroup$

1 Answer 1

6
$\begingroup$

The following approach seems to work:

SetOptions[$FrontEndSession, {Background -> None, 
   FontProperties -> {"ScreenResolution" -> 96}}];

SetOptions[EvaluationNotebook[], {Background -> LightBlue, 
   FontProperties -> {"ScreenResolution" -> 72}}];

pl = Plot[Sinc[x], {x, 0, 10}, Epilog -> Text[Style[Sinc[x], 16], {5.5, 1/2}], 
  ImageSize -> Small]

Rasterize[Style[pl, Options[EvaluationNotebook[]]]]

screenshot

It is possible to achieve better quality by specifying higher ImageResolution:

Rasterize[Style[pl, Options[EvaluationNotebook[]]], ImageResolution -> 200]

screenshot

$\endgroup$
1
  • $\begingroup$ I thought I tried "ScreenResolution" in Style and it didn't work which is why I emphasized that aspect. However I am thrilled to learn that it does! Thank you! I'll test this a bit further and wait 24 hours as I have made customary before accepting, but it seems to be the solution I needed. $\endgroup$ Commented Sep 8, 2015 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.