So I've developed this simple code

Mes /: MakeBoxes[Mes[mess_, error_, unit_], 
                 form : (StandardForm | TraditionalForm) : StandardForm
                ] := RowBox[{
                   MakeBoxes[NumberForm[Quantity[mess ± error, unit], {20, 2}], form]}]

in order to easily print things like this:

NumberForm[Quantity[1 ± 0.1, "picoFarads"], {20, 2}]

which give a nice output:

(1.00 ± 0.10) pF

but using the Mes structure:

Mes[1, 0.1, "picoFarads"]

gives me:

Quantity[1.00 ± 0.10,picoFarads]

On the other hand:

Mes[1, 0.1, "Farads"]


(1.00 ± 0.10) F

I'm not sure what's going on but it seems to be connected with internet connection needed to interpret the units. How can I make MakeBoxes wait for the unit to get interpreted?


1 Answer 1


You can let the unit be interpreted before calling the MakeBoxes:

Mes /: MakeBoxes[
         Mes[mess_, error_, unit_], 
         form : (StandardForm | TraditionalForm) : StandardForm] := 

          With[{u = QuantityUnit@ Quantity[1, unit]}, 
               MakeBoxes[NumberForm[Quantity[mess ± error, u], {20, 2}], form]

For your example:

Mes[1, 0.1, "picoFarads"]

enter image description here


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.