Rewrite Rulesphysics/physics-operator-fence-expand

physics/physics-operator-fence-expand

Expand the physics auto-sized argument of exp, det, and Pr into an explicit fence.

Rewrite patterns#

  1. operator-brace\exp{#1}\exp\left\{#1\right\}
  2. operator-bracket\exp[#1]\exp\left[#1\right]
  3. operator-paren\exp(#1)\exp\left(#1\right)

Examples#

Each example shows this rule applied in isolation. A complete normalization profile may make additional changes.

Operator brace#

Before

\exp{\frac{x}{y}}

After this rule

\exp\left\{\frac{x}{y}\right\}

The rendered result has pixel differences from the input.

Operator bracket literal paren#

Before

\exp[\frac{x}{y}](t)

After this rule

\exp\left[\frac{x}{y}\right](t)

The rendered result has pixel differences from the input.

Operator paren#

Before

\det(\frac{A}{2})

After this rule

\det\left(\frac{A}{2}\right)

The rendered result has pixel differences from the input.

Operator paren ordinary after#

Before

\Pr(A)B

After this rule

\Pr\left(A\right)B

The rendered result has pixel differences from the input.

Upstream rules#

Same family#

Notes#

Semantics follow LaTeX physics.sty 1.3. These names use \opbraces (g o d()): only the first of \exp{...}, \exp[...], \exp(...) and the matching forms of \det and \Pr becomes an auto-sized fence; later brackets or parentheses stay literal. The physics records hold that first group as one paired d<(,)><[,]><{,}> slot, so the parser attaches it, matching nested delimiters as xparse does, and a group that separates the name from the delimiter, as in {\exp}(x), keeps the delimiter literal. The rule leaves unchanged a bare name and a command that carries scripts (\det_A(x)); an unclosed delimiter is a parse error, as in LaTeX. Touches-only convergence: every Applied removes one physics operator with an attached argument (the argument becomes a \left...\right fence); non-matching nodes return Skipped. Only the physics records of these names carry that slot, so enabled_by_packages derives to physics and the rule key belongs to physics; a base-only context keeps \exp(x) unchanged. Fidelity is reading: physics closes the fence inside \mathopen{}\mathclose\bgroup...\egroup, which acts as a closing atom, while an explicit \left...\right fence is an inner atom. The explicit fence therefore adds about 1/6 em before the opening delimiter and another 1/6 em after the fence when an ordinary atom or an opening delimiter follows, about 1/3 em in the worst case; script styles show no difference. No compensating space is inserted. MathJax differs: MathJax physics hides the braces of \exp{...} and prints \exp[...] literally, while LaTeX shows auto-sized braces and brackets. In display style, LaTeX places the scripts of \det_A and \Pr_X below the operator and MathJax places them beside it; the rule does not rewrite these scripted commands.

Disable this rule#

TransformEngine(profile="corpus", disable_rules=["physics/physics-operator-fence-expand"])
new TransformEngine({ profile: 'corpus', disableRules: ['physics/physics-operator-fence-expand'] })

Open in Playground