4

It seems there are two independent, equally influential values those control mathematica notebook magnification.
Just like volume bars in a certain media player(program) and volume bar in tray bar(right side of windows 10 taskbar).

One is the following, the familiar one. :

enter image description here

We can get the value by

 CurrentValue[Magnification]
 1.25 (1.25 means 125%)

(Note that if you see 125% in the lower-right corner of mathematica but the value isn't 1.25, you might have already touched on the more unfamiliar things that will be explained next.)

But I do not know how to change the value by executing a code. <- This is the first question.

The other is less familar. By default, the value is 1. You can change the value by executing the code

SetOptions[$FrontEndSession, Magnification -> 1.3] (* 130% *)

But I do not know how to identify(=figure out) the value. <- This is the second question.

If we set these two values to 125% and 1.3, then the final magnification becomes 1.25*1.3 = 1.625.

Note that it seems neither the two values can change the final size(we see by our eye) in image in output cell.
See : Creating a size changing image in output cell

imida k
  • 4,285
  • 9
  • 17
  • Try: FrontEndExecute[SetOptions[$FrontEndSession, Magnification -> 1.5]] – Daniel Huber Apr 05 '23 at 07:33
  • 1
    Thank you, but the effect of your code is the same as SetOptions[$FrontEndSession, Magnification -> 1.5] which is already mentioned in the original post. You can read my question more carefully! – imida k Apr 05 '23 at 09:46
  • 1
    Technically, there a 'N' values. Global, Notebook, Cell, and the Box level settings. Just experiment with multiple, nested Styles. Style[{"aaa", Style["bbb", Magnification -> .5 * Inherited], "ccc"}, Magnification -> 6] – ihojnicki Apr 05 '23 at 17:18
  • Thank you for similar method for Style ! – imida k Apr 06 '23 at 20:40

1 Answers1

4

One of them belongs to the whole front-end (session) and will affect all open notebooks, the other belongs to a particular notebook. Read more about option hierarchy in @Mr. Wizard's answer.

Use CurrentValue or Options to get the value, and CurrentValue or SetOptions to set the value. Read more about this in the Tutorial on Manipulating Notebooks.

(* Get *)
CurrentValue[$FrontEndSession, Magnification]
Options[$FrontEndSession, Magnification]

CurrentValue[EvaluationNotebook[], Magnification] Options[EvaluationNotebook[], Magnification]

(* Set *) SetOptions[$FrontEndSession, Magnification -> 2] SetOptions[EvaluationNotebook[], Magnification -> 2]

CurrentValue[$FrontEndSession, Magnification] = 2 CurrentValue[EvaluationNotebook[], Magnification] = 2

Note that you can also use CurrentValue[Magnification] because CurrentValue by default refers to the location at which it appears in a notebook structure.

Moreover, Magnification can also be set for a particular Cell.

(* Get *)
Options[First@Cells[], Magnification]
CurrentValue[First@Cells[], Magnification]

(* Set *) SetOptions[First@Cells[], Magnification -> 2] CurrentValue[First@Cells[], Magnification] = 2

Domen
  • 23,608
  • 1
  • 27
  • 45
  • For symmetries sake, it might be worth noting that CurrentValue[$FrontEndSession, Magnification] = 1.5 will also set the magnification, and Options[$FrontEndSession, Magnification] can also read out the current value – Lukas Lang Apr 05 '23 at 13:38
  • @LukasLang, thanks, I updated my answer! Too many different ways to obtain the same effect :) – Domen Apr 05 '23 at 14:51