Skip to main content
1 of 2
Bob Hanlon
  • 162.7k
  • 7
  • 81
  • 205
Clear["Global`*"]

Create a wrapper for adding a Tooltip to a Quantity

qTooltip[q_Quantity, tt_String] :=
 Tooltip[QuantityForm[q, "Abbreviation"], tt]

Like other wrappers (e.g., MatrixForm), the wrapper should not be included in variable definitions.

qTooltip[quant = Quantity[1, "Month"], "how to make it work?"]

(* Tooltip[1*"mo", "how to make it work?", 
   TooltipStyle -> "TextStyling"] *)

The definition of quant does not include the wrapper.

QuantityMagnitude[quant]

(* 1 *)

UnitConvert[quant, "days"]

(* Quantity[365/12, "Days"] *)
Bob Hanlon
  • 162.7k
  • 7
  • 81
  • 205