Rewrite Rulesbase/pmatrix-to-pmatrix-env

base/pmatrix-to-pmatrix-env

Rewrite plain-TeX pmatrix to the standard pmatrix environment with row breaks.

Rewrite patterns#

  1. cr\pmatrix{#1 \cr #2}\begin{pmatrix} #1 \\ #2 \end{pmatrix}
  2. linebreak-arguments\pmatrix{#1 \\*[#2] #3}\begin{pmatrix} #1 \\*[#2] #3 \end{pmatrix}
  3. newline\pmatrix{#1 \newline #2}\begin{pmatrix} #1 \\ #2 \end{pmatrix}
  4. leading-row-scripts\pmatrix{#1 \cr_{#2}^{#3}#4}\begin{pmatrix} #1 \\{}_{#2}^{#3}#4 \end{pmatrix}
  5. leading-row-primes\pmatrix{#1 \cr'#2}\begin{pmatrix} #1 \\{}'#2 \end{pmatrix}

Examples#

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

Three by three parenthesized matrix#

Before

\pmatrix{a_{11} & a_{12} & 0 \cr a_{21} & a_{22} & 1 \cr 0 & 1 & \lambda}

After this rule

\begin{pmatrix} a_{11} & a_{12} & 0 \\ a_{21} & a_{22} & 1 \\ 0 & 1 & \lambda \end{pmatrix}

The rendered result has pixel differences from the input.

Ams pmatrix env out of scope#

Before

\begin{pmatrix} x \\ y \end{pmatrix}

After this rule

\begin{pmatrix} x \\ y \end{pmatrix}

Rendering verified with the declared packages.

Downstream rules#

Same family#

Notes#

Convert only known body-level \cr, \\, and \newline row separators. Normalize \cr and \newline to an unstarred linebreak with no spacing argument; preserve the original star and optional spacing slots on \\ (including \\*, \\[2pt], and \\*[2pt]). Split a separator through any Scripted base chain, transfer its leading subscript, superscript, and Prime content to a fresh empty base at the start of the next row, and preserve nested script layers. Do not split separators inside explicit groups or nested environments, and leave unknown names such as \crcr untouched. Preserve real internal empty rows and the body sequence, including trailing separators. Only the plain-TeX source command is eliminated; existing AMS environments are out of scope.

Disable this rule#

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

Open in Playground