11

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)?

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
User18
  • 882
  • 4
  • 12
  • 4
    I thought that would be enough SetOptions[ EvaluationNotebook[], {Magnification -> 1, GraphicsBoxOptions -> {BaseStyle -> Magnification -> 1} } ] but it seems I missed something. – Kuba Mar 11 '16 at 12:48
  • @Kuba :) What do you mean saying you have missed something? – User18 Mar 11 '16 at 12:51
  • It doesn't work for me :) – Kuba Mar 11 '16 at 12:53
  • Oh. Well, for instance, if I want the magnification to be 1.12, but want to keep the images exactly the same size as before, what code should be used? – User18 Mar 11 '16 at 13:00
  • 2
    @Kuba Your solution works very well for me (with OS X, mma 10.3.1) – SquareOne Mar 11 '16 at 13:14
  • @User18 First Maginification -> 1.12 I copied wrong number :) But it seems it doesn't work on Win. – Kuba Mar 11 '16 at 13:17
  • @Kuba It works on my win7; however it magnifies only the current notebook where the code is run, but not the Help docs. – User18 Mar 11 '16 at 13:29
  • 1
    Yep, that was meant to be done by this example. You have to edit Reference Stylesheet Notebook styles similarly to: http://mathematica.stackexchange.com/a/81016/5478 – Kuba Mar 11 '16 at 13:31
  • Thank you Kuba! That link needs my studying and I will try my best. :) – User18 Mar 11 '16 at 14:10
  • @Kuba After quite some tinkering I have found that GraphicsBoxOptions -> {BaseStyle -> Magnification -> 1} governs only images generated by Mathematica via plotting, and that it has no effect on images directly imported by Mathematica, such as that one attached above, fetched as an image file by the Help browser from the hard disk. It seems that RasterBoxOptions may be relevant to the magnification of imported raster images, but my trial has been unsuccessful. – User18 Mar 13 '16 at 04:39
  • 1
    @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 – Kuba Mar 13 '16 at 08:49
  • @Kuba Well it looks like a really complicated matter. – User18 Mar 13 '16 at 10:23
  • 1
    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.) – Michael E2 Jul 09 '16 at 23:43

2 Answers2

7

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

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
  • 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! – User18 Aug 10 '16 at 09:24
  • @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. – Alexey Popkov Aug 10 '16 at 09:50
  • 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! – User18 Aug 10 '16 at 17:02
1

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}]
Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368