Add the mathinner spacing class
This commit is contained in:
1 parent
33125d1f16
commit
a0bb8be2ac
2 files changed
+13
No files matched your search
@@ -118,6 +118,7 @@ pub enum MathClass {
|
|||||||
Open,
|
Open,
|
||||||
Close,
|
Close,
|
||||||
Punctuation,
|
Punctuation,
|
||||||
|
Inner,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn math_class(character: char) -> MathClass {
|
pub fn math_class(character: char) -> MathClass {
|
||||||
@@ -144,6 +145,8 @@ fn spacing_mu(left: MathClass, right: MathClass) -> i64 {
|
|||||||
(Ordinary, Binary) | (Binary, Ordinary) => 4,
|
(Ordinary, Binary) | (Binary, Ordinary) => 4,
|
||||||
(Ordinary, Relation) | (Relation, Ordinary) => 5,
|
(Ordinary, Relation) | (Relation, Ordinary) => 5,
|
||||||
(Binary, Relation) | (Relation, Binary) => 0,
|
(Binary, Relation) | (Relation, Binary) => 0,
|
||||||
|
(Inner, Inner) => 0,
|
||||||
|
(Inner, _) | (_, Inner) => 3,
|
||||||
(Ordinary, Ordinary) => 0,
|
(Ordinary, Ordinary) => 0,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
@@ -635,6 +638,7 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
|||||||
"mathopen" => MathClass::Open,
|
"mathopen" => MathClass::Open,
|
||||||
"mathclose" => MathClass::Close,
|
"mathclose" => MathClass::Close,
|
||||||
"mathpunct" => MathClass::Punctuation,
|
"mathpunct" => MathClass::Punctuation,
|
||||||
|
"mathinner" => MathClass::Inner,
|
||||||
_ => MathClass::Ordinary,
|
_ => MathClass::Ordinary,
|
||||||
};
|
};
|
||||||
(
|
(
|
||||||
@@ -936,6 +940,13 @@ mod tests {
|
|||||||
assert!(sum.depth > plain.depth);
|
assert!(sum.depth > plain.depth);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
|
fn mathinner_adds_three_mu_on_both_sides() {
|
||||||
|
let font = Cmr10Metrics::default();
|
||||||
|
let plain = layout_math(&parse_math("axb"), &font);
|
||||||
|
let inner = layout_math(&parse_math(r"a\mathinner{x}b"), &font);
|
||||||
|
assert!(inner.width > plain.width + 10_000);
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
fn mathrel_wrapper_forces_relation_spacing() {
|
fn mathrel_wrapper_forces_relation_spacing() {
|
||||||
let font = Cmr10Metrics::default();
|
let font = Cmr10Metrics::default();
|
||||||
let plain = layout_math(&parse_math("a+b"), &font);
|
let plain = layout_math(&parse_math("a+b"), &font);
|
||||||
|
|||||||
@@ -204,3 +204,5 @@ for a later overlaid slash.
|
|||||||
`\bmod`/`\pmod{n}` parse to upright `mod` rows, with `\pmod` wrapping its argument in `(mod ...)`.
|
`\bmod`/`\pmod{n}` parse to upright `mod` rows, with `\pmod` wrapping its argument in `(mod ...)`.
|
||||||
|
|
||||||
`\pmod{n}` is a `Classed` relation, and `\not` inherits the base atom's math class for spacing.
|
`\pmod{n}` is a `Classed` relation, and `\not` inherits the base atom's math class for spacing.
|
||||||
|
|
||||||
|
`\mathinner{...}` uses `MathClass::Inner` with 3mu on either side.
|
||||||
Reference in new issue
Block a user