11
$\begingroup$

In Mathematica's Option Inspector I set the notebook magnification factor to be larger than 1, for example 1.12 ("Notebook Options"->"Display Options"). Accordingly contents of the Documentation Center are all magnified including the images which now look like this:

zigzag image after magnification

As shown above the lines in the images after magnification are in a zigzag fashion and ugly to look at.

So is there a way to set the notebook magnification factor above 1, without affecting the images (that is, without magnifying the images)?

$\endgroup$
13
  • 4
    $\begingroup$ I thought that would be enough SetOptions[ EvaluationNotebook[], {Magnification -> 1, GraphicsBoxOptions -> {BaseStyle -> Magnification -> 1} } ] but it seems I missed something. $\endgroup$
    – Kuba
    Mar 11, 2016 at 12:48
  • 2
    $\begingroup$ @Kuba Your solution works very well for me (with OS X, mma 10.3.1) $\endgroup$
    – SquareOne
    Mar 11, 2016 at 13:14
  • 1
    $\begingroup$ Yep, that was meant to be done by this example. You have to edit Reference Stylesheet Notebook styles similarly to: mathematica.stackexchange.com/a/81016/5478 $\endgroup$
    – Kuba
    Mar 11, 2016 at 13:31
  • 1
    $\begingroup$ @User18 yes, same here, images are wrapped with GraphicsBox too so I thought it will work it doesn't. Maybe because they are handled separately by FE: What governs images resizing in the FrontEnd environment $\endgroup$
    – Kuba
    Mar 13, 2016 at 8:49
  • 1
    $\begingroup$ The solution of @Kuba works for me this way, too: SetOptions[ $FrontEndSession, GraphicsBoxOptions -> {BaseStyle -> Magnification -> 1}], but, of course, that affects all notebooks throughout the session. It does have the advantage of persistence whenever you change the doc page. (OSX 10.11.5, M V10.4.1.) $\endgroup$
    – Michael E2
    Jul 9, 2016 at 23:43

2 Answers 2

7
$\begingroup$

If you look at the BoxForm of the rasterized output in the Documentation Center by selecting it and pressing Ctrl+Shift+E, you'll see that GraphicsBox containing the rasterized plot has the option DefaultBaseStyle -> "ImageGraphics". So we can control magnification of such elements by adding to the Notebook's private stylesheet the following definition for the style "ImageGraphics":

Cell[StyleData["ImageGraphics"], Magnification->1]

This works great for any ordinary Notebook but applying this option to the Documentation Notebooks is tricky since they have the option Editable -> False and it isn't recommended to edit them. By default they have set StyleDefinitions -> FrontEnd`FileName[{"Wolfram"}, "Reference.nb", CharacterEncoding -> "UTF-8"] and hence their styles are defined in the stylesheet "Reference.nb" located in the folder

FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", "StyleSheets", "Wolfram"}]

You can make a copy of this stylesheet, remove the Editable -> False and Saveable -> False options and then edit the "ImageGraphics" style (located in the "FormatType and Automatic Styles" section). Then you can copy this file to the following folder and then restart Mathematica:

FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "StyleSheets", "Wolfram"}]  

Stylesheets from this folder have higher priority than from the previous because it is located earlier in the StyleSheetPath global FrontEnd setting:

AbsoluteOptions[$FrontEnd, StyleSheetPath]
{StyleSheetPath -> {FrontEnd`FileName[{$UserBaseDirectory, "Autoload", _, 
     "FrontEnd", "StyleSheets"}], 
   FrontEnd`FileName[{$UserBaseDirectory, "Applications", _, "FrontEnd", 
     "StyleSheets"}], 
   FrontEnd`FileName[{$BaseDirectory, "Autoload", _, "FrontEnd", 
     "StyleSheets"}], 
   FrontEnd`FileName[{$BaseDirectory, "Applications", _, "FrontEnd", 
     "StyleSheets"}], 
   FrontEnd`FileName[{$InstallationDirectory, "AddOns", "Autoload", _, 
     "FrontEnd", "StyleSheets"}], 
   FrontEnd`FileName[{$InstallationDirectory, "AddOns", "Applications", _, 
     "FrontEnd", "StyleSheets"}], 
   FrontEnd`FileName[{$UserBaseDirectory, "SystemFiles", "FrontEnd", 
     "StyleSheets"}], 
   FrontEnd`FileName[{$BaseDirectory, "SystemFiles", "FrontEnd", 
     "StyleSheets"}], 
   FrontEnd`FileName[{$InstallationDirectory, "Configuration", "FrontEnd", 
     "StyleSheets"}], 
   FrontEnd`FileName[{$InstallationDirectory, "SystemFiles", "Components", _, 
     "FrontEnd", "StyleSheets"}], 
   FrontEnd`FileName[{$InstallationDirectory, "SystemFiles", "FrontEnd", 
     "StyleSheets"}], 
   FrontEnd`FileName[{"C:\\Program Files\\Wolfram Research\\Mathematica\\10.4\
\\SystemFiles\\Components\\MUnit\\FrontEnd", "StyleSheets"}, 
    "PacletManager" -> True]}}

All the above operations can be completely automatized:

CreateDirectory[
 FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "StyleSheets", 
   "Wolfram"}]];
CopyFile @@ (FileNameJoin[{#, "SystemFiles", "FrontEnd", "StyleSheets", 
       "Wolfram", 
       "Reference.nb"}] & /@ {$InstallationDirectory, $UserBaseDirectory});
nb = NotebookOpen[
   FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "StyleSheets",
      "Wolfram", "Reference.nb"}]];
SetOptions[nb, {Editable -> True, Saveable -> True}];

NotebookFind[nb, "ImageGraphics"];
cell = NotebookRead[nb];
If[TrueQ[First@cell === StyleData["ImageGraphics"]], 
 NotebookWrite[nb, Append[cell, Magnification -> 1], All]; NotebookSave[nb], $Failed]

(then restart Mathematica).

I have tested the above and it works! Screenshot:

screenshot

$\endgroup$
3
  • $\begingroup$ This answer is a pleasant surprise to me; I thought that this problem did not have a solution, but now, after trying your method, I have really solved it. Thank you! $\endgroup$
    – User18
    Aug 10, 2016 at 9:24
  • $\begingroup$ @User18 Have you restarted Mathematica after copying modified "Reference.nb" into the subdirectory of $UserBaseDirectory? I checked my solution with version 10.4.1 on Windows 7 x64 and it works perfectly, no need to replace the original file in the $InstallationDirectory. $\endgroup$ Aug 10, 2016 at 9:50
  • $\begingroup$ Ah, everything worked fine after the second time I did it according to your instruction; so I deleted that error report as soon as I succeeded, which you still saw nevertheless. (I did restart Mathematica in my first attempt, so why I did not get the right result then - it is now a mystery to me.) Thank you again; the ugly zigzag lines in the magnified images are finally gone! $\endgroup$
    – User18
    Aug 10, 2016 at 17:02
1
$\begingroup$

The solution suggested in the comments works too:

SetOptions[$FrontEnd, GraphicsBoxOptions -> {BaseStyle -> Magnification -> 1}]

But of course this affects all Notebooks, not only the Documentation Notebooks. And moreover it affects not only raster graphics but all 2D graphics in the Notebooks...

For reverting to the defaults one should evaluate

SetOptions[$FrontEnd, GraphicsBoxOptions -> {BaseStyle -> Inherited}]
$\endgroup$
1
  • $\begingroup$ Oh, I see. So we have two alternatives. Thank you. $\endgroup$
    – User18
    Aug 23, 2016 at 9:21

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.