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.
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
- DisableFormatting prevents formatting of expressions inside Hold, HoldComplete, and other functions with the HoldFirst, HoldRest, HoldAll, and HoldAllComplete attributes.
- DisableFormatting usually displays expressions in InputForm.
- The DisableFormatting wrapper is not visible in StandardForm and TraditionalForm.
Examples
open all close allBasic Examples (3)
Prevent an expression from formatting:
Hold[DisableFormatting[Grid[{{a, b}, {x, y}}]]]Release the hold to let it format:
ReleaseHold[%]Prevent an unevaluated expression from formatting:
HoldForm[DisableFormatting[Integrate[x, x]]]Releasing the hold allows evaluation and, subsequently, formatting to occur:
ReleaseHold[%]DisableFormatting must appear inside held expression or it will evaluate away:
DisableFormatting[x]FullForm[%]Scope (3)
DisableFormatting works inside any function with held attributes like HoldAll:
SetAttributes[f, HoldAll]
f[DisableFormatting[x ^ 2], DisableFormatting[y ^ 2]]Attributes[If]If[a, DisableFormatting[x ^ 2], DisableFormatting[y ^ 2]]Attributes[Delayed]Delayed[DisableFormatting[x ^ 2]]Attributes[Assert]Assert[DisableFormatting[x ^ 2 == y ^ 2]]Disable the formatting in held expressions:
Hold[DisableFormatting[Row[{a, " ", b}]]]x :> DisableFormatting[Sqrt[x]]Evaluate held parts to restore the normal formatting:
{ReleaseHold[%%], x /. %}DisableFormatting is invisible in StandardForm and TraditionalForm:
Hold[DisableFormatting[2a]]TraditionalForm[%]InputForm and FullForm show DisableFormatting:
InputForm[%]FullForm[%]Properties & Relations (5)
Hold, HoldForm and other functions that hold their arguments prevent evaluation but not typesetting:
HoldForm[2 ^ 2]DisableFormatting inside of Hold prevents the unevaluated expression from typesetting:
HoldForm[DisableFormatting[2 ^ 2]]However, DisableFormatting does not by itself hold its argument or prevent typesetting:
DisableFormatting[2 ^ 2]In a HoldFirst or HoldRest function, DisableFormatting only affects the held arguments:
Attributes[If]If[DisableFormatting[Graphics[Disk[]]], DisableFormatting[Graphics[Disk[]]]]Attributes[Delayed]Delayed[DisableFormatting[Graphics[Disk[]]], DisableFormatting[Graphics[Disk[]]]]Defer prevents an expression from evaluating but not typesetting:
Defer[Integrate[Cos[x], x]]If copied and pasted, that expression will then evaluate:
∫Cos[x]ⅆxIf using DisableFormatting along with Defer, the expression will neither evaluate nor typeset:
Defer[DisableFormatting[∫Cos[x]ⅆx]]However, on copy and paste, it evaluates and therefore typesets normally:
DisableFormatting[Integrate[Cos[x], x]]Interpretation assigns an arbitrary appearance to an output expression:
res = Interpretation[InputForm[#], #]&@Grid[{{1, 2}, {3, 4}}, Background -> GrayLevel[.7]]If copied and pasted, normal interpretation and typesetting follow:
Grid[{{1, 2}, {3, 4}}, Background -> GrayLevel[0.7]]However, the original expression remains unevaluated:
res//InputFormWith DisableFormatting, the normal evaluation and formatting is restored once the hold is released:
HoldForm[DisableFormatting[Grid[{{1, 2}, {3, 4}}, Background -> StandardBlue]]]ReleaseHold[%]On the other hand, copy and paste will preserve the DisableFormatting wrapper:
DisableFormatting[Grid[{{1, 2}, {3, 4}}, Background -> StandardBlue]]Inactivate creates an expression that sometimes, but not always, avoids 2D typesetting:
Inactivate[D[x ^ p, x]]The result is a different expression, where each head h has been replaced by Inactive[h]:
%//InputFormDisableFormatting always avoids 2D typesetting, and the input expression returns unchanged:
HoldForm[DisableFormatting[D[x ^ p, p]]]%//InputFormSee Also
Related Guides
History
Text
Wolfram Research (2016), DisableFormatting, Wolfram Language function, https://reference.wolfram.com/language/ref/DisableFormatting.html.
CMS
Wolfram Language. 2016. "DisableFormatting." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DisableFormatting.html.
APA
Wolfram Language. (2016). DisableFormatting. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DisableFormatting.html
BibTeX
@misc{reference.wolfram_2026_disableformatting, author="Wolfram Research", title="{DisableFormatting}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/DisableFormatting.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_disableformatting, organization={Wolfram Research}, title={DisableFormatting}, year={2016}, url={https://reference.wolfram.com/language/ref/DisableFormatting.html}, note=[Accessed: 13-June-2026]}