Is it possible to set a default set of units for output?

I've just discovered the joys of units and Quantity. Ideally, I'd like to be able to tell Mathematica to always convert to SI units. I'm aware I could UnitConvert every entry, but that's not what I'm after: I want to set and forget. Is this possible, and if so, how?

Digging around the docs is making me think the answer is "No, it isn't", which is disappointing.


This is not the same as setting the units to default in metric. My default is metric. However, Mathematica will keep things in pre-defined quantities if I use them. As an arbitrary example, consider below:

mass = 10 Quantity["SolarMass"]
inertia = 2/5 mass 

The output of this is

Quantity[10, "SolarMass"]
Quantity[400, ("Meters")^2 "SolarMass"]

i.e. it does not convert from solar mass units, even though my unit system is metric. I could explicitly tell it to convert every line, but that's what I'm trying to avoid.

  • 3
    $\begingroup$ You can always use $Post = Replace[q_Quantity:>UnitConvert[q]] $\endgroup$
    – b3m2a1
    Jan 17, 2018 at 5:52
  • 1
    $\begingroup$ .. or $Post =If[Head[#] === Quantity, UnitConvert[#], #]& or $PrePrint = If[Head[#] === Quantity, UnitConvert[#], #]&. $\endgroup$
    – kglr
    Jan 17, 2018 at 5:57
  • $\begingroup$ Also possible duplicate: mathematica.stackexchange.com/q/44639/12 $\endgroup$
    – Szabolcs
    Jan 17, 2018 at 9:38
  • $\begingroup$ You could add the line $UnitSystem = "Metric" to your init.m file. $\endgroup$
    – Jason B.
    Jan 17, 2018 at 12:25
  • 1
    $\begingroup$ I am voting to reopen this post so that @b3m2a1 can convert his/her comment into an answer. Moreover, OP made clear that this is not a precise duplicate. $\endgroup$ Jan 18, 2018 at 7:59


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.

Browse other questions tagged or ask your own question.