# base/buildrel-to-stackrel

Rewrite plain TeX buildrel syntax to stackrel.

https://texform.dev/rules/base/buildrel-to-stackrel

## Metadata

| Field | Value |
| --- | --- |
| Key | base/buildrel-to-stackrel |
| Level | authoring |
| Fidelity | render |
| Enabled by packages | base |
| Profiles | Authoring, Faithful, Corpus, Equiv |

## Rewrite patterns

### operator

From:

```latex
\buildrel #1 \over #2
```

To:

```latex
\stackrel{#1}{#2}
```

### operator-external-scripts

From:

```latex
\buildrel #1 \over #2_{#3}^{#4}
```

To:

```latex
\stackrel{#1}{#2}_{#3}^{#4}
```

## Examples

Examples show the rule in isolation, not a complete normalization profile.

### Asymptotic relation stack

Before:

```latex
A_n \buildrel n\to\infty \over = B_n
```

After this rule:

```latex
A_n \stackrel{n\to\infty}{=} B_n
```

Packages: base.

Rendering verified with the declared packages.

### Arrow relation stack

Before:

```latex
X \buildrel \phi \over \longrightarrow Y
```

After this rule:

```latex
X \stackrel{\phi}{\longrightarrow} Y
```

Packages: base.

Rendering verified with the declared packages.

## Triggers

- [\\buildrel](https://texform.dev/latex/commands/buildrel)

## Eliminates

- [\\buildrel](https://texform.dev/latex/commands/buildrel)

## Produces

- [\\stackrel](https://texform.dev/latex/commands/stackrel)

## Downstream

- [base/stackrel-expand](https://texform.dev/rules/base/stackrel-expand): Expand stackrel to an explicit relation-level stacked operator form.

## Same family

- [ams/substack-expand](https://texform.dev/rules/ams/substack-expand): Expand substack directly to the explicit centered subarray environment.
- [base/duplicate-mathrel-wrapper-drop](https://texform.dev/rules/base/duplicate-mathrel-wrapper-drop): Drop one directly nested duplicate mathrel wrapper.
- [base/widehat-to-hat](https://texform.dev/rules/base/widehat-to-hat): Drop stretchiness from \widehat by rewriting it to \hat.
- [base/widetilde-to-tilde](https://texform.dev/rules/base/widetilde-to-tilde): Drop stretchiness from \widetilde by rewriting it to \tilde.
- [base/stackbin-expand](https://texform.dev/rules/base/stackbin-expand): Expand stackbin to an explicit binary-level stacked operator form.
- [base/stackrel-expand](https://texform.dev/rules/base/stackrel-expand): Expand stackrel to an explicit relation-level stacked operator form.

## Notes

buildrel has argspec u{\over} m: the annotation is read up to a level-0 \over and the operator is the following mandatory argument, so \over is ArgumentKind::Until delimiter metadata rather than a sibling infix node and touches is empty. As for a TeX delimited parameter, an annotation that is exactly one braced group loses that brace layer at parse time; a \over inside braces is not a terminator. Scripts after the operator argument stay attached to the whole stackrel, while scripts inside a braced operator stay inside it. stackrel is the accepted Authoring form; Faithful expands it further through stackrel-expand. Like other unbraced mandatory arguments, an unbraced compound operator such as \frac{a}{b} is accepted as one argument even though TeX would reject it.

## Disable this rule

```python
TransformEngine(profile="corpus", disable_rules=["base/buildrel-to-stackrel"])
```

```javascript
new TransformEngine({ profile: 'corpus', disableRules: ['base/buildrel-to-stackrel'] })
```

[Open in Playground](https://play.texform.dev/?input=A_n+%5Cbuildrel+n%5Cto%5Cinfty+%5Cover+%3D+B_n)
