4
$\begingroup$

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

$\endgroup$
4
  • $\begingroup$ Try: FrontEndExecute[SetOptions[$FrontEndSession, Magnification -> 1.5]] $\endgroup$ Apr 5, 2023 at 7:33
  • 1
    $\begingroup$ 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! $\endgroup$
    – imida k
    Apr 5, 2023 at 9:46
  • 1
    $\begingroup$ 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] $\endgroup$
    – ihojnicki
    Apr 5, 2023 at 17:18
  • $\begingroup$ Thank you for similar method for Style ! $\endgroup$
    – imida k
    Apr 6, 2023 at 20:40

1 Answer 1

4
$\begingroup$

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
$\endgroup$
2
  • $\begingroup$ 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 $\endgroup$
    – Lukas Lang
    Apr 5, 2023 at 13:38
  • $\begingroup$ @LukasLang, thanks, I updated my answer! Too many different ways to obtain the same effect :) $\endgroup$
    – Domen
    Apr 5, 2023 at 14:51

Your Answer

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

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