Rename formula to equation

This commit is contained in:
Laurenz 2023-03-18 19:27:31 +01:00
parent a16726ae66
commit a69b587455
21 changed files with 102 additions and 101 deletions

View File

@ -49,8 +49,8 @@ Let's disect what's going on:
- We insert a heading with the `= Heading` syntax. One equals sign creates a top
level heading, two create a subheading and so on.
- [Math formulas][math] are enclosed in dollar signs. By adding extra spaces
around the contents of a formula, we can put it into a separate block.
- [Mathematical equations][math] are enclosed in dollar signs. By adding extra
spaces around the contents of a equation, we can put it into a separate block.
Multi-letter identifiers are interpreted as Typst definitions and functions
unless put into quotes. This way, we don't need backslashes for things like
`floor` and `sqrt`. And `phi.alt` applies the `alt` modifier to the `phi` to

View File

@ -27,7 +27,7 @@
"overbracket",
]
description: |
Delimiters above or below parts of a formula.
Delimiters above or below parts of an equation.
The braces and brackets further allow you to add an optional annotation
below or above themselves.
@ -44,7 +44,7 @@
Subscript, superscripts, and limits.
The `attach` function backs the `[$a_b^c$]` syntax that adds top and bottom
attachments to a part of a formula. Attachments can be displayed either as
attachments to a part of an equation. Attachments can be displayed either as
sub/superscripts, or limits. Typst automatically decides which is more
suitable depending on the base, but you can also control this manually with
the `scripts` and `limits` functions.

View File

@ -40,10 +40,11 @@ more about their syntax and usage.
## Math mode { #math }
Math mode is a special markup mode that is used to typeset mathematical
formulas. It is entered by wrapping a formula in `[$]` characters. The formula
will be typeset into its own block if it starts and ends with at least one space
(e.g. `[$ x^2 $]`). Inline math can be produced by omitting the whitespace (e.g.
`[$x^2$]`). An overview over the syntax specific to math mode follows:
formulas. It is entered by wrapping an equation in `[$]` characters. The
equation will be typeset into its own block if it starts and ends with at least
one space (e.g. `[$ x^2 $]`). Inline math can be produced by omitting the
whitespace (e.g. `[$x^2$]`). An overview over the syntax specific to math mode
follows:
| Name | Example | See |
| ---------------------- | ------------------------ | ------------------------ |

View File

@ -261,7 +261,7 @@ pub struct BlockNode {
///
/// ```example
/// #set align(center)
/// #show math.formula: set block(above: 8pt, below: 16pt)
/// #show math.equation: set block(above: 8pt, below: 16pt)
///
/// This sum of $x$ and $y$:
/// $ x + y = z $

View File

@ -50,7 +50,7 @@ use typst::diag::SourceResult;
use typst::eval::Tracer;
use typst::model::{applicable, realize, SequenceNode, StyleVecBuilder, StyledNode};
use crate::math::{FormulaNode, LayoutMath};
use crate::math::{EquationNode, LayoutMath};
use crate::meta::DocumentNode;
use crate::prelude::*;
use crate::shared::BehavedBuilder;
@ -245,9 +245,9 @@ impl<'a, 'v, 't> Builder<'a, 'v, 't> {
mut content: &'a Content,
styles: StyleChain<'a>,
) -> SourceResult<()> {
if content.can::<dyn LayoutMath>() && !content.is::<FormulaNode>() {
if content.can::<dyn LayoutMath>() && !content.is::<EquationNode>() {
content =
self.scratch.content.alloc(FormulaNode::new(content.clone()).pack());
self.scratch.content.alloc(EquationNode::new(content.clone()).pack());
}
if let Some(styled) = content.to::<StyledNode>() {
@ -491,7 +491,7 @@ impl<'a> ParBuilder<'a> {
|| content.is::<HNode>()
|| content.is::<LinebreakNode>()
|| content.is::<SmartQuoteNode>()
|| content.to::<FormulaNode>().map_or(false, |node| !node.block(styles))
|| content.to::<EquationNode>().map_or(false, |node| !node.block(styles))
|| content.is::<BoxNode>()
{
self.0.push(content.clone(), styles);

View File

@ -7,7 +7,7 @@ use typst::model::StyledNode;
use super::{BoxNode, HNode, Sizing, Spacing};
use crate::layout::AlignNode;
use crate::math::FormulaNode;
use crate::math::EquationNode;
use crate::prelude::*;
use crate::text::{
shape, LinebreakNode, Quoter, Quotes, ShapedText, SmartQuoteNode, SpaceNode, TextNode,
@ -324,8 +324,8 @@ enum Segment<'a> {
Text(usize),
/// Horizontal spacing between other segments.
Spacing(Spacing),
/// A math formula.
Formula(&'a FormulaNode),
/// A mathematical equation.
Equation(&'a EquationNode),
/// A box with arbitrary content.
Box(&'a BoxNode, bool),
/// Metadata.
@ -339,7 +339,7 @@ impl Segment<'_> {
Self::Text(len) => len,
Self::Spacing(_) => SPACING_REPLACE.len_utf8(),
Self::Box(_, true) => SPACING_REPLACE.len_utf8(),
Self::Formula(_) | Self::Box(_, _) | Self::Meta => NODE_REPLACE.len_utf8(),
Self::Equation(_) | Self::Box(_, _) | Self::Meta => NODE_REPLACE.len_utf8(),
}
}
}
@ -597,9 +597,9 @@ fn collect<'a>(
full.push(if node.double(styles) { '"' } else { '\'' });
}
Segment::Text(full.len() - prev)
} else if let Some(node) = child.to::<FormulaNode>() {
} else if let Some(node) = child.to::<EquationNode>() {
full.push(NODE_REPLACE);
Segment::Formula(node)
Segment::Equation(node)
} else if let Some(node) = child.to::<BoxNode>() {
let frac = node.width(styles).is_fractional();
full.push(if frac { SPACING_REPLACE } else { NODE_REPLACE });
@ -671,9 +671,9 @@ fn prepare<'a>(
items.push(Item::Fractional(v, None));
}
},
Segment::Formula(formula) => {
Segment::Equation(equation) => {
let pod = Regions::one(region, Axes::splat(false));
let mut frame = formula.layout(vt, styles, pod)?.into_frame();
let mut frame = equation.layout(vt, styles, pod)?.into_frame();
frame.translate(Point::with_y(TextNode::baseline_in(styles)));
items.push(Item::Frame(frame));
}

View File

@ -211,7 +211,7 @@ fn items() -> LangItems {
node.pack()
},
term_item: |term, description| layout::TermItem::new(term, description).pack(),
formula: |body, block| math::FormulaNode::new(body).with_block(block).pack(),
equation: |body, block| math::EquationNode::new(body).with_block(block).pack(),
math_align_point: || math::AlignPointNode::new().pack(),
math_delimited: |open, body, close| math::LrNode::new(open + body + close).pack(),
math_attach: |base, bottom, top| {

View File

@ -47,7 +47,7 @@ use crate::text::{
/// Create a module with all math definitions.
pub fn module() -> Module {
let mut math = Scope::deduplicating();
math.define("formula", FormulaNode::id());
math.define("equation", EquationNode::id());
math.define("text", TextNode::id());
// Grouping.
@ -106,7 +106,7 @@ pub fn module() -> Module {
Module::new("math").with_scope(math)
}
/// A mathematical formula.
/// A mathematical equation.
///
/// Can be displayed inline with text or as a separate block.
///
@ -125,25 +125,25 @@ pub fn module() -> Module {
///
/// ## Syntax
/// This function also has dedicated syntax: Write mathematical markup within
/// dollar signs to create a formula. Starting and ending the formula with at
/// dollar signs to create an equation. Starting and ending the equation with at
/// least one space lifts it into a separate block that is centered
/// horizontally. For more details about math syntax, see the
/// [main math page]($category/math).
///
/// Display: Formula
/// Display: Equation
/// Category: math
#[node(Show, Finalize, Layout, LayoutMath)]
pub struct FormulaNode {
/// Whether the formula is displayed as a separate block.
pub struct EquationNode {
/// Whether the equation is displayed as a separate block.
#[default(false)]
pub block: bool,
/// The content of the formula.
/// The contents of the equation.
#[required]
pub body: Content,
}
impl Show for FormulaNode {
impl Show for EquationNode {
fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
let mut realized = self.clone().pack().guarded(Guard::Base(NodeId::of::<Self>()));
if self.block(styles) {
@ -153,7 +153,7 @@ impl Show for FormulaNode {
}
}
impl Finalize for FormulaNode {
impl Finalize for EquationNode {
fn finalize(&self, realized: Content, _: StyleChain) -> Content {
realized
.styled(TextNode::set_weight(FontWeight::from_number(450)))
@ -163,7 +163,7 @@ impl Finalize for FormulaNode {
}
}
impl Layout for FormulaNode {
impl Layout for EquationNode {
fn layout(
&self,
vt: &mut Vt,
@ -209,7 +209,7 @@ pub trait LayoutMath {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()>;
}
impl LayoutMath for FormulaNode {
impl LayoutMath for EquationNode {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
self.body().layout_math(ctx)
}

View File

@ -2,7 +2,7 @@ use typst::eval::Scope;
use super::*;
/// A text operator in a math formula.
/// A text operator in an equation.
///
/// ## Example
/// ```example

View File

@ -11,7 +11,7 @@ use super::*;
/// Category: math
#[node(LayoutMath)]
pub struct BoldNode {
/// The piece of formula to style.
/// The content to style.
#[required]
pub body: Content,
}
@ -36,7 +36,7 @@ impl LayoutMath for BoldNode {
/// Category: math
#[node(LayoutMath)]
pub struct UprightNode {
/// The piece of formula to style.
/// The content to style.
#[required]
pub body: Content,
}
@ -58,7 +58,7 @@ impl LayoutMath for UprightNode {
/// Category: math
#[node(LayoutMath)]
pub struct ItalicNode {
/// The piece of formula to style.
/// The content to style.
#[required]
pub body: Content,
}
@ -80,7 +80,7 @@ impl LayoutMath for ItalicNode {
/// Category: math
#[node(LayoutMath)]
pub struct SerifNode {
/// The piece of formula to style.
/// The content to style.
#[required]
pub body: Content,
}
@ -105,7 +105,7 @@ impl LayoutMath for SerifNode {
/// Category: math
#[node(LayoutMath)]
pub struct SansNode {
/// The piece of formula to style.
/// The content to style.
#[required]
pub body: Content,
}
@ -130,7 +130,7 @@ impl LayoutMath for SansNode {
/// Category: math
#[node(LayoutMath)]
pub struct CalNode {
/// The piece of formula to style.
/// The content to style.
#[required]
pub body: Content,
}
@ -155,7 +155,7 @@ impl LayoutMath for CalNode {
/// Category: math
#[node(LayoutMath)]
pub struct FrakNode {
/// The piece of formula to style.
/// The content to style.
#[required]
pub body: Content,
}
@ -180,7 +180,7 @@ impl LayoutMath for FrakNode {
/// Category: math
#[node(LayoutMath)]
pub struct MonoNode {
/// The piece of formula to style.
/// The content to style.
#[required]
pub body: Content,
}
@ -210,7 +210,7 @@ impl LayoutMath for MonoNode {
/// Category: math
#[node(LayoutMath)]
pub struct BbNode {
/// The piece of formula to style.
/// The content to style.
#[required]
pub body: Content,
}
@ -224,7 +224,7 @@ impl LayoutMath for BbNode {
}
}
/// Text properties in a formula.
/// Text properties in math.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct MathStyle {
/// The style variant to select.
@ -298,7 +298,7 @@ impl MathStyle {
}
}
/// The size of elements in a formula.
/// The size of elements in an equation.
///
/// See the TeXbook p. 141.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]

View File

@ -77,18 +77,18 @@ pub struct LangItems {
pub enum_item: fn(number: Option<NonZeroUsize>, body: Content) -> Content,
/// An item in a term list: `/ Term: Details`.
pub term_item: fn(term: Content, description: Content) -> Content,
/// A mathematical formula: `$x$`, `$ x^2 $`.
pub formula: fn(body: Content, block: bool) -> Content,
/// An alignment point in a formula: `&`.
/// A mathematical equation: `$x$`, `$ x^2 $`.
pub equation: fn(body: Content, block: bool) -> Content,
/// An alignment point in math: `&`.
pub math_align_point: fn() -> Content,
/// Matched delimiters surrounding math in a formula: `[x + y]`.
/// Matched delimiters in math: `[x + y]`.
pub math_delimited: fn(open: Content, body: Content, close: Content) -> Content,
/// A base with optional attachments in a formula: `a_1^2`.
/// A base with optional attachments in math: `a_1^2`.
pub math_attach:
fn(base: Content, bottom: Option<Content>, top: Option<Content>) -> Content,
/// A base with an accent: `arrow(x)`.
pub math_accent: fn(base: Content, accent: char) -> Content,
/// A fraction in a formula: `x/2`.
/// A fraction in math: `x/2`.
pub math_frac: fn(num: Content, denom: Content) -> Content,
/// Dispatch a method on a library value.
pub library_method: fn(
@ -126,7 +126,7 @@ impl Hash for LangItems {
self.list_item.hash(state);
self.enum_item.hash(state);
self.term_item.hash(state);
self.formula.hash(state);
self.equation.hash(state);
self.math_align_point.hash(state);
self.math_delimited.hash(state);
self.math_attach.hash(state);

View File

@ -426,7 +426,7 @@ impl Eval for ast::Expr {
Self::List(v) => v.eval(vm).map(Value::Content),
Self::Enum(v) => v.eval(vm).map(Value::Content),
Self::Term(v) => v.eval(vm).map(Value::Content),
Self::Formula(v) => v.eval(vm).map(Value::Content),
Self::Equation(v) => v.eval(vm).map(Value::Content),
Self::Math(v) => v.eval(vm).map(Value::Content),
Self::MathIdent(v) => v.eval(vm),
Self::MathAlignPoint(v) => v.eval(vm).map(Value::Content),
@ -626,13 +626,13 @@ impl Eval for ast::TermItem {
}
}
impl Eval for ast::Formula {
impl Eval for ast::Equation {
type Output = Content;
fn eval(&self, vm: &mut Vm) -> SourceResult<Self::Output> {
let body = self.body().eval(vm)?;
let block = self.block();
Ok((vm.items.formula)(body, block))
Ok((vm.items.equation)(body, block))
}
}

View File

@ -45,7 +45,7 @@ impl<'a> Scopes<'a> {
.ok_or("unknown variable")?)
}
/// Try to access a variable immutably from within a math formula.
/// Try to access a variable immutably in math.
pub fn get_in_math(&self, var: &str) -> StrResult<&Value> {
Ok(std::iter::once(&self.top)
.chain(self.scopes.iter().rev())

View File

@ -237,13 +237,13 @@ fn markup_completions(ctx: &mut CompletionContext) {
ctx.snippet_completion(
"math (inline)",
"$${x}$",
"Inserts an inline-level mathematical formula.",
"Inserts an inline-level mathematical equation.",
);
ctx.snippet_completion(
"math (block)",
"$ ${sum_x^2} $",
"Inserts a block-level mathematical formula.",
"Inserts a block-level mathematical equation.",
);
}
@ -251,7 +251,7 @@ fn markup_completions(ctx: &mut CompletionContext) {
fn complete_math(ctx: &mut CompletionContext) -> bool {
if !matches!(
ctx.leaf.parent_kind(),
Some(SyntaxKind::Formula)
Some(SyntaxKind::Equation)
| Some(SyntaxKind::Math)
| Some(SyntaxKind::MathFrac)
| Some(SyntaxKind::MathAttach)
@ -935,10 +935,10 @@ impl<'a> CompletionContext<'a> {
/// Add completions for all font families.
fn font_completions(&mut self) {
let formula = self.before[self.cursor.saturating_sub(25)..].contains("formula");
let equation = self.before[self.cursor.saturating_sub(25)..].contains("equation");
for (family, iter) in self.world.book().families() {
let detail = summarize_font_family(iter);
if !formula || family.contains("Math") {
if !equation || family.contains("Math") {
self.value_completion(
None,
&Value::Str(family.into()),
@ -1121,7 +1121,7 @@ impl<'a> CompletionContext<'a> {
let in_math = matches!(
self.leaf.parent_kind(),
Some(SyntaxKind::Formula)
Some(SyntaxKind::Equation)
| Some(SyntaxKind::Math)
| Some(SyntaxKind::MathFrac)
| Some(SyntaxKind::MathAttach)

View File

@ -27,9 +27,9 @@ pub enum Tag {
ListMarker,
/// A term in a term list.
ListTerm,
/// The delimiters of a math formula.
/// The delimiters of an equation.
MathDelimiter,
/// An operator with special meaning in a math formula.
/// An operator with special meaning in an equation.
MathOperator,
/// A keyword.
Keyword,
@ -138,7 +138,7 @@ pub fn highlight(node: &LinkedNode) -> Option<Tag> {
SyntaxKind::EnumMarker => Some(Tag::ListMarker),
SyntaxKind::TermItem => None,
SyntaxKind::TermMarker => Some(Tag::ListMarker),
SyntaxKind::Formula => None,
SyntaxKind::Equation => None,
SyntaxKind::Math => None,
SyntaxKind::MathIdent => highlight_ident(node),

View File

@ -112,19 +112,19 @@ pub enum Expr {
Enum(EnumItem),
/// An item in a term list: `/ Term: Details`.
Term(TermItem),
/// A math formula: `$x$`, `$ x^2 $`.
Formula(Formula),
/// A math formula: `$x$`, `$ x^2 $`.
/// A mathematical equation: `$x$`, `$ x^2 $`.
Equation(Equation),
/// The contents of a mathematical equation: `x^2 + 1`.
Math(Math),
/// An identifier in a math formula: `pi`.
/// An identifier in math: `pi`.
MathIdent(MathIdent),
/// An alignment point in a math formula: `&`.
/// An alignment point in math: `&`.
MathAlignPoint(MathAlignPoint),
/// Matched delimiters surrounding math in a formula: `[x + y]`.
/// Matched delimiters in math: `[x + y]`.
MathDelimited(MathDelimited),
/// A base with optional attachments in a formula: `a_1^2`.
/// A base with optional attachments in math: `a_1^2`.
MathAttach(MathAttach),
/// A fraction in a math formula: `x/2`.
/// A fraction in math: `x/2`.
MathFrac(MathFrac),
/// An identifier: `left`.
Ident(Ident),
@ -214,7 +214,7 @@ impl AstNode for Expr {
SyntaxKind::ListItem => node.cast().map(Self::List),
SyntaxKind::EnumItem => node.cast().map(Self::Enum),
SyntaxKind::TermItem => node.cast().map(Self::Term),
SyntaxKind::Formula => node.cast().map(Self::Formula),
SyntaxKind::Equation => node.cast().map(Self::Equation),
SyntaxKind::Math => node.cast().map(Self::Math),
SyntaxKind::MathIdent => node.cast().map(Self::MathIdent),
SyntaxKind::MathAlignPoint => node.cast().map(Self::MathAlignPoint),
@ -273,7 +273,7 @@ impl AstNode for Expr {
Self::List(v) => v.as_untyped(),
Self::Enum(v) => v.as_untyped(),
Self::Term(v) => v.as_untyped(),
Self::Formula(v) => v.as_untyped(),
Self::Equation(v) => v.as_untyped(),
Self::Math(v) => v.as_untyped(),
Self::MathIdent(v) => v.as_untyped(),
Self::MathAlignPoint(v) => v.as_untyped(),
@ -696,17 +696,17 @@ impl TermItem {
}
node! {
/// A math formula: `$x$`, `$ x^2 $`.
Formula
/// A mathemathical equation: `$x$`, `$ x^2 $`.
Equation
}
impl Formula {
impl Equation {
/// The contained math.
pub fn body(&self) -> Math {
self.0.cast_first_match().unwrap_or_default()
}
/// Whether the formula should be displayed as a separate block.
/// Whether the equation should be displayed as a separate block.
pub fn block(&self) -> bool {
let is_space = |node: Option<&SyntaxNode>| {
node.map(SyntaxNode::kind) == Some(SyntaxKind::Space)
@ -716,7 +716,7 @@ impl Formula {
}
node! {
/// Math markup.
/// The contents of a mathematical equation: `x^2 + 1`.
Math
}
@ -728,7 +728,7 @@ impl Math {
}
node! {
/// An identifier in a math formula: `pi`.
/// An identifier in math: `pi`.
MathIdent
}
@ -758,12 +758,12 @@ impl Deref for MathIdent {
}
node! {
/// An alignment point in a formula: `&`.
/// An alignment point in math: `&`.
MathAlignPoint
}
node! {
/// Matched delimiters surrounding math in a formula: `[x + y]`.
/// Matched delimiters in math: `[x + y]`.
MathDelimited
}
@ -785,7 +785,7 @@ impl MathDelimited {
}
node! {
/// A base with optional attachments in a formula: `a_1^2`.
/// A base with optional attachments in math: `a_1^2`.
MathAttach
}
@ -813,7 +813,7 @@ impl MathAttach {
}
node! {
/// A fraction in a formula: `x/2`
/// A fraction in math: `x/2`
MathFrac
}

View File

@ -56,18 +56,18 @@ pub enum SyntaxKind {
TermItem,
/// Introduces a term item: `/`.
TermMarker,
/// A mathematical formula: `$x$`, `$ x^2 $`.
Formula,
/// A mathematical equation: `$x$`, `$ x^2 $`.
Equation,
/// Mathematical markup.
/// The contents of a mathematical equation: `x^2 + 1`.
Math,
/// An identifier in math: `pi`.
MathIdent,
/// An alignment point in math: `&`.
MathAlignPoint,
/// Matched delimiters surrounding math in a formula: `[x + y]`.
/// Matched delimiters in math: `[x + y]`.
MathDelimited,
/// A base with optional attachments in a formula: `a_1^2`.
/// A base with optional attachments in math: `a_1^2`.
MathAttach,
/// A fraction in math: `x/2`.
MathFrac,
@ -100,7 +100,7 @@ pub enum SyntaxKind {
Star,
/// Toggles emphasized text and indicates a subscript in math: `_`.
Underscore,
/// Starts and ends a math formula: `$`.
/// Starts and ends a mathematical equation: `$`.
Dollar,
/// The unary plus and binary addition operator: `+`.
Plus,
@ -342,7 +342,7 @@ impl SyntaxKind {
Self::EnumMarker => "enum marker",
Self::TermItem => "term list item",
Self::TermMarker => "term marker",
Self::Formula => "math formula",
Self::Equation => "equation",
Self::Math => "math",
Self::MathIdent => "math identifier",
Self::MathAlignPoint => "math alignment point",

View File

@ -114,7 +114,7 @@ fn markup_expr(p: &mut Parser, at_start: &mut bool) {
SyntaxKind::EnumMarker if *at_start => enum_item(p),
SyntaxKind::TermMarker if *at_start => term_item(p),
SyntaxKind::RefMarker => reference(p),
SyntaxKind::Dollar => formula(p),
SyntaxKind::Dollar => equation(p),
SyntaxKind::LeftBracket
| SyntaxKind::RightBracket
@ -213,14 +213,14 @@ fn whitespace_line(p: &mut Parser) {
}
}
fn formula(p: &mut Parser) {
fn equation(p: &mut Parser) {
let m = p.marker();
p.enter(LexMode::Math);
p.assert(SyntaxKind::Dollar);
math(p, |kind| kind == SyntaxKind::Dollar);
p.expect(SyntaxKind::Dollar);
p.exit();
p.wrap(m, SyntaxKind::Formula);
p.wrap(m, SyntaxKind::Equation);
}
fn math(p: &mut Parser, mut stop: impl FnMut(SyntaxKind) -> bool) {
@ -631,7 +631,7 @@ fn code_primary(p: &mut Parser, atomic: bool) {
SyntaxKind::LeftBrace => code_block(p),
SyntaxKind::LeftBracket => content_block(p),
SyntaxKind::LeftParen => with_paren(p),
SyntaxKind::Dollar => formula(p),
SyntaxKind::Dollar => equation(p),
SyntaxKind::Let => let_binding(p),
SyntaxKind::Set => set_rule(p),
SyntaxKind::Show => show_rule(p),

View File

@ -1,6 +1,6 @@
// Integrated test for content fields.
#let compute(formula, ..vars) = {
#let compute(equation, ..vars) = {
let vars = vars.named()
let f(node) = {
let func = node.func()
@ -28,14 +28,14 @@
.fold(0, (sum, v) => sum + v)
}
}
let result = f(formula.body)
let result = f(equation.body)
[With ]
vars
.pairs()
.map(p => $#p.first() = #p.last()$)
.join(", ", last: " and ")
[ we have:]
$ formula = result $
$ equation = result $
}
#compute($x y + y^2$, x: 2, y: 3)

View File

@ -10,7 +10,7 @@ $ sum_(i=#emoji.apple)^#emoji.apple.red i + monkey/2 $
$ x := #table(columns: 2)[x][y]/mat(1, 2, 3)
= #table[A][B][C] $
---
// Test non-formula math directly in content.
// Test non-equation math directly in content.
#math.attach($a$, top: [b])
---

View File

@ -26,5 +26,5 @@ $text(#red, "time"^2) + sqrt("place")$
---
// Test different font.
#show math.formula: set text(font: "Fira Math")
#show math.equation: set text(font: "Fira Math")
$ v := vec(1 + 2, 2 - 4, sqrt(3), arrow(x)) + 1 $