large operators have limits in displays; relations have limits always (#1748)

This commit is contained in:
damaxwell 2023-08-02 14:27:33 -08:00 committed by GitHub
parent 3c94e05ced
commit cd163868f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 16 deletions

View File

@ -216,10 +216,16 @@ pub enum Limits {
impl Limits { impl Limits {
/// The default limit configuration if the given character is the base. /// The default limit configuration if the given character is the base.
pub fn for_char(c: char) -> Self { pub fn for_char(c: char) -> Self {
if Self::DEFAULT_TO_LIMITS.contains(&c) { match unicode_math_class::class(c) {
Limits::Display Some(MathClass::Large) => {
} else { if is_integral_char(c) {
Limits::Never Limits::Never
} else {
Limits::Display
}
}
Some(MathClass::Relation) => Limits::Always,
_ => Limits::Never,
} }
} }
@ -231,18 +237,6 @@ impl Limits {
Self::Never => false, Self::Never => false,
} }
} }
/// Unicode codepoints that should show attachments as limits in display
/// mode.
#[rustfmt::skip]
const DEFAULT_TO_LIMITS: &[char] = &[
/**/ '\u{220F}', /**/ '\u{2210}', /**/ '\u{2211}',
/**/ '\u{22C0}', /* */ '\u{22C1}',
/**/ '\u{22C2}', /* */ '\u{22C3}',
/**/ '\u{2A00}', /**/ '\u{2A01}', /**/ '\u{2A02}',
/**/ '\u{2A03}', /**/ '\u{2A04}',
/**/ '\u{2A05}', /**/ '\u{2A06}',
];
} }
macro_rules! measure { macro_rules! measure {
@ -444,6 +438,11 @@ fn compute_shifts_up_and_down(
(shift_up, shift_down) (shift_up, shift_down)
} }
/// Determines if the character is one of a variety of integral signs
fn is_integral_char(c: char) -> bool {
('∫'..='∳').contains(&c) || ('⨋'..='⨜').contains(&c)
}
/// Whether the fragment consists of a single character or atomic piece of text. /// Whether the fragment consists of a single character or atomic piece of text.
fn is_character_box(fragment: &MathFragment) -> bool { fn is_character_box(fragment: &MathFragment) -> bool {
match fragment { match fragment {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -22,3 +22,21 @@ $ attach(A, t: #locate(it => oops)) $
#show math.iota: math.limits.with(inline: false) #show math.iota: math.limits.with(inline: false)
#eq #eq
$iota_a^b$ $iota_a^b$
---
// Test default of limit attachments on relations at all sizes
#set page(width: auto)
$ a =^"def" b quad a lt.eq_"really" b quad a arrow.r.long.squiggly^"slowly" b $
$a =^"def" b quad a lt.eq_"really" b quad a arrow.r.long.squiggly^"slowly" b$
$a scripts(=)^"def" b quad a scripts(lt.eq)_"really" b quad a scripts(arrow.r.long.squiggly)^"slowly" b$
---
// Test default of scripts attachments on integrals at display size
$ integral.sect_a^b quad \u{2a1b}_a^b quad limits(\u{2a1b})_a^b $
$integral.sect_a^b quad \u{2a1b}_a^b quad limits(\u{2a1b})_a^b$
---
// Test default of limit attachments on large operators at display size only
$ tack.t.big_0^1 quad \u{02A0A}_0^1 quad join_0^1 $
$tack.t.big_0^1 quad \u{02A0A}_0^1 quad join_0^1$