DisableFormatting

DisableFormatting[expr]

is a form that disables the formatting of expr when it appears inside held expressions, but gives expr as soon as evaluation occurs.

Details

Examples

open allclose all

Basic Examples  (3)

Prevent an expression from formatting:

Release the hold to let it format:

Prevent an unevaluated expression from formatting:

Releasing the hold allows evaluation and, subsequently, formatting to occur:

DisableFormatting must appear inside held expression or it will evaluate away:

Scope  (3)

DisableFormatting works inside any function with held attributes like HoldAll:

HoldRest:

HoldFirst:

HoldAllComplete:

Disable the formatting in held expressions:

Evaluate held parts to restore the normal formatting:

DisableFormatting is invisible in StandardForm and TraditionalForm:

InputForm and FullForm show DisableFormatting:

Properties & Relations  (5)

Hold, HoldForm and other functions that hold their arguments prevent evaluation but not typesetting:

DisableFormatting inside of Hold prevents the unevaluated expression from typesetting:

However, DisableFormatting does not by itself hold its argument or prevent typesetting:

In a HoldFirst or HoldRest function, DisableFormatting only affects the held arguments:

Defer prevents an expression from evaluating but not typesetting:

If copied and pasted, that expression will then evaluate:

If using DisableFormatting along with Defer, the expression will neither evaluate nor typeset:

However, on copy and paste, it evaluates and therefore typesets normally:

Interpretation assigns an arbitrary appearance to an output expression:

If copied and pasted, normal interpretation and typesetting follow:

However, the original expression remains unevaluated:

With DisableFormatting, the normal evaluation and formatting is restored once the hold is released:

On the other hand, copy and paste will preserve the DisableFormatting wrapper:

Inactivate creates an expression that sometimes, but not always, avoids 2D typesetting:

The result is a different expression, where each head h has been replaced by Inactive[h]:

DisableFormatting always avoids 2D typesetting, and the input expression returns unchanged:

Introduced in 2016
 (11.0)