Rewrite Rulesbase/root-of-to-sqrt

base/root-of-to-sqrt

Rewrite legacy root-of syntax to bracketed sqrt notation.

Rewrite patterns#

  1. degree\root #1 \of #2\sqrt[#1]{#2}
  2. empty-degree\root\of #1\sqrt[]{#1}

Examples#

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

Compound root#

Before

\root 1+2 \of {x+y}

After this rule

\sqrt[1+2]{x+y}

Rendering verified with the declared packages.

Same family#

Notes#

Consume the two parser-owned argument slots from root argspec u{\of} m: a mathematical degree terminated by \of, followed by one radicand argument. The degree may be empty or contain unbraced scripts and nested groups. As for a TeX delimited parameter, a degree that is exactly one braced group loses that brace layer at parse time, so \root{1+2}\of x and \root 1+2\of x are the same AST. The \of terminator is ArgumentKind::Until delimiter metadata, not a sibling Command node, so touches is empty. Preserve outer scripts and trailing radicand siblings.

Disable this rule#

TransformEngine(profile="corpus", disable_rules=["base/root-of-to-sqrt"])
new TransformEngine({ profile: 'corpus', disableRules: ['base/root-of-to-sqrt'] })

Open in Playground