Make dot be multiplication and add dot.period for periods (#747)

This commit is contained in:
Alex Saveau 2023-04-19 10:08:59 -07:00 committed by GitHub
parent f08ae95b9d
commit b285bea41d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 17 deletions

View File

@ -31,7 +31,7 @@ math: |
```example ```example
$ A = pi r^2 $ $ A = pi r^2 $
$ "area" = pi dot.op "radius"^2 $ $ "area" = pi dot "radius"^2 $
$ cal(A) := $ cal(A) :=
{ x in RR | x "is natural" } $ { x in RR | x "is natural" } $
#let x = 5 #let x = 5
@ -39,7 +39,7 @@ math: |
``` ```
Math mode makes a wide selection of [symbols]($category/symbols/sym) like Math mode makes a wide selection of [symbols]($category/symbols/sym) like
`pi`, `dot.op`, or `RR` available. Many mathematical symbols are available in `pi`, `dot`, or `RR` available. Many mathematical symbols are available in
different variants. You can select between different variants by applying different variants. You can select between different variants by applying
[modifiers]($type/symbol) to the symbol. Typst further recognizes a number of [modifiers]($type/symbol) to the symbol. Typst further recognizes a number of
shorthand sequences like `=>` that approximate a symbol. When such a shorthand shorthand sequences like `=>` that approximate a symbol. When such a shorthand

View File

@ -10,7 +10,7 @@ const VERTICAL_PADDING: Ratio = Ratio::new(0.1);
/// ///
/// ## Example /// ## Example
/// ```example /// ```example
/// $ vec(a, b, c) dot.op vec(1, 2, 3) /// $ vec(a, b, c) dot vec(1, 2, 3)
/// = a + 2b + 3c $ /// = a + 2b + 3c $
/// ``` /// ```
/// ///
@ -135,7 +135,7 @@ impl LayoutMath for MatElem {
/// ## Example /// ## Example
/// ```example /// ```example
/// $ f(x, y) := cases( /// $ f(x, y) := cases(
/// 1 "if" (x dot.op y)/2 <= 0, /// 1 "if" (x dot y)/2 <= 0,
/// 2 "if" x "is even", /// 2 "if" x "is even",
/// 3 "if" x in NN, /// 3 "if" x in NN,
/// 4 "else", /// 4 "else",

View File

@ -64,12 +64,12 @@ pub(crate) const SYM: &[(&str, Symbol)] = symbols! {
// Punctuation. // Punctuation.
amp: ['&', inv: ''], amp: ['&', inv: ''],
ast: [ ast: [
'*', basic: '*',
op: '',
low: '', low: '',
double: '', double: '',
triple: '', triple: '',
small: '', small: '',
op: '',
circle: '', circle: '',
sq: '', sq: '',
], ],
@ -89,8 +89,8 @@ pub(crate) const SYM: &[(&str, Symbol)] = symbols! {
wave.double: '', wave.double: '',
], ],
dot: [ dot: [
'.',
op: '', op: '',
basic: '.',
c: '·', c: '·',
circle: '', circle: '',
circle.big: '', circle.big: '',
@ -111,10 +111,10 @@ pub(crate) const SYM: &[(&str, Symbol)] = symbols! {
section: '§', section: '§',
semi: [';', rev: ''], semi: [';', rev: ''],
slash: ['/', double: '', triple: ''], slash: ['/', double: '', triple: ''],
dots: [h: '', h.c: '', v: '', down: '', up: ''], dots: [h.c: '', h: '', v: '', down: '', up: ''],
tilde: [ tilde: [
'~',
op: '', op: '',
basic: '~',
eq: '', eq: '',
eq.not: '', eq.not: '',
eq.rev: '', eq.rev: '',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -2,7 +2,7 @@
--- ---
$ f(x, y) := cases( $ f(x, y) := cases(
1 quad &"if" (x dot.op y)/2 <= 0, 1 quad &"if" (x dot y)/2 <= 0,
2 &"if" x divides 2, 2 &"if" x divides 2,
3 &"if" x in NN, 3 &"if" x in NN,
4 &"else", 4 &"else",

View File

@ -3,12 +3,12 @@
--- ---
// Test semicolon syntax. // Test semicolon syntax.
#set align(center) #set align(center)
$mat() dot.op $mat() dot
mat(;) dot.op mat(;) dot
mat(1, 2) dot.op mat(1, 2) dot
mat(1, 2;) \ mat(1, 2;) \
mat(1; 2) dot.op mat(1; 2) dot
mat(1, 2; 3, 4) dot.op mat(1, 2; 3, 4) dot
mat(1 + &2, 1/2; &3, 4)$ mat(1 + &2, 1/2; &3, 4)$
--- ---

View File

@ -4,13 +4,13 @@
// Test basic alignment. // Test basic alignment.
$ x &= x + y \ $ x &= x + y \
&= x + 2z \ &= x + 2z \
&= sum x dot.op 2z $ &= sum x dot 2z $
--- ---
// Test text before first alignment point. // Test text before first alignment point.
$ x + 1 &= a^2 + b^2 \ $ x + 1 &= a^2 + b^2 \
y &= a + b^2 \ y &= a + b^2 \
z &= alpha dot.op beta $ z &= alpha dot beta $
--- ---
// Test space between inner alignment points. // Test space between inner alignment points.

View File

@ -13,6 +13,10 @@ $ underline(f' : NN -> RR) \
1 - 0 thick &..., 1 - 0 thick &...,
) $ ) $
---
// Test common symbols.
$ dot \ dots \ ast \ tilde \ star $
--- ---
// Error: 1:3 expected dollar sign // Error: 1:3 expected dollar sign
$a $a