Rewrite Rulesbase/hskip-to-hspace

base/hskip-to-hspace

Collapse hskip to the explicit hspace command.

Rewrite patterns#

  1. \hskip #1\hspace{#1}

Examples#

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

hskip between symbols#

Before

A \hskip 1em B

After this rule

A \hspace{1em} B

Rendering verified with the declared packages.

hskip decimal em length#

Before

u\hskip 0.25em v

After this rule

u\hspace{0.25em} v

Rendering verified with the declared packages.

Text hskip between glyphs#

Before

\text{A\hskip 1em B}

After this rule

\text{A\hspace{1em}B}

Rendering verified with the declared packages.

Text hskip braced space loss#

Before

\text{A\hskip{1em} B}

After this rule

\text{A\hspace{1em}B}

The rendered result has pixel differences from the input.

Same family#

Notes#

MathJax's unbraced Hskip dimension scanner consumes one ASCII space after the unit, while a braced dimension preserves following text space. TeXForm's AST does not retain whether a scalar dimension was braced, so this rule canonicalizes the common primitive form by consuming one following U+0020 in text content. A braced text source can therefore lose an intentional space, making worst-case fidelity approximate. The base record remains the single owner; text examples include textmacros to cover the same-name text record. The produced hspace follows the current s m:L signature in math and text modes: emit an explicit false Star slot before the Dimension slot. This rewrite remains unstarred and does not introduce \hspace*; serialization and reparsing preserve the two-slot argument shape.

Disable this rule#

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

Open in Playground