Add support for weak elements in math (#1633)

This commit is contained in:
bluebear94 2023-07-06 03:37:19 -04:00 committed by GitHub
parent 5bdad06d92
commit a4756d8576
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 1 deletions

View File

@ -47,6 +47,7 @@ use crate::meta::{
Count, Counter, CounterUpdate, LocalName, Numbering, Outlinable, Refable,
};
use crate::prelude::*;
use crate::shared::BehavedBuilder;
use crate::text::{
families, variant, FontFamily, FontList, LinebreakElem, SpaceElem, TextElem, TextSize,
};
@ -414,7 +415,11 @@ impl LayoutMath for Content {
}
if let Some(children) = self.to_sequence() {
let mut bb = BehavedBuilder::new();
for child in children {
bb.push(child.clone(), StyleChain::default());
}
for (child, _) in bb.finish().0.iter() {
child.layout_math(ctx)?;
}
return Ok(());

View File

@ -60,7 +60,7 @@ macro_rules! ops {
);)*
let dif = |d| {
HElem::new(THIN.into()).pack()
HElem::new(THIN.into()).with_weak(true).pack()
+ MathStyleElem::new(TextElem::packed(d)).with_italic(Some(false)).pack()
};
math.define("dif", dif('d'));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -20,6 +20,11 @@ $ binom(circle, square) $
// Error: 8-13 missing argument: lower
$ binom(x^2) $
---
// Test dif.
$ (dif y)/(dif x), dif/x, x/dif, dif/dif \
frac(dif y, dif x), frac(dif, x), frac(x, dif), frac(dif, dif) $
---
// Test associativity.
$ 1/2/3 = (1/2)/3 = 1/(2/3) $