2
$\begingroup$

How to overwrite the display function of TemplateBox? For example, if I have:

NotebookWrite[InputNotebook[],  ToBoxes@Quantity[3, "Meters"]]

how do I overwrite the DisplayFunction to make the out put display differently, without changing the actual value of the output?

$\endgroup$
4
$\begingroup$

Boxes are just like any other expression when they are evaluated by the kernel, so one way to achieve this is with replacement rules:

ToBoxes@Quantity[3, "Meters"] /.
  (DisplayFunction -> _) -> (DisplayFunction -> (RowBox@{#1, " метра"} &)) // RawBoxes

3 метра

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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