Math FormattingCreate professionally typeset math equations using a small number of formatting primitives. View on YouTube
SymbolsUse the Symbol function to create objects that behave like algebraic symbols. The second argument is the tip that pops up when the mouse is hovered over the symbol. x = Symbol("x", "The independent variable 'x'");y = Symbol("y", "The independent variable 'y'");RaisePower(a, b) = Span { a; " raised to the power of "; b; " is "; a ^ b;};Powers = Block { RaisePower(2, 5); // Perform calculation with numbers RaisePower(x, y); // Create formula};2 raised to the power of 5 is 32x raised to the power of y is xyThe independent variable 'y'
FractionsCreate several different types of common fractions with the Fraction formatter.FormatFraction = Fraction { x; y+1;};xy + 1
Slanted FractionsFormat the fraction with a diagonal slash by setting the diagonal argument to true. SlantedFraction = Fraction(true) { x; y ^ 2;};xy2
Compact FractionsCreate a more compact fraction layout by setting the compact argument to true. ThreeQuarters = Fraction(false, true) {3; 4};CompactFraction = Span { "Add "; ThreeQuarters; " of a cup of flour. ";};Add 34 of a cup of flour.
Compact Fraction ShortcutFor numeric fractions, get a more concise expression by using a rational number. OneHalf = 1 over 2;CompactShortcut = Span { "Add "; OneHalf; " teaspoon of sugar and stir. ";};Add 12 teaspoon of sugar and stir.
TextDiagonal PropertyChange the default rational number display to a diagonal bar by settting the TextDiagonal property to true. CompactSlanted = Span { TextDiagonal: true; "Mix in "; 4 over 3; " tablespoons of warm water if the dough is too firm. ";};Mix in 113 tablespoons of warm water if the dough is too firm.
SubscriptsAdd a subscript to a symbol by using the sub operator. X1 = x sub 1;x1
SuperscriptsUse the sup operator in the same way to make superscripts. E = Symbol("E", "Energy");m = Symbol("m", "Mass");c = Symbol("c", "The speed of light");MassEnergy = Span {E; Tex.Equals; m; c sup 2};E = mc2The speed of light
RadicalsSquare-root symbols can be created with the Radical formatter. Solution = Paragraph { "The solution is: "; Tex.pm; Radical { x; Tex.Plus; 2; };};The solution is:  ± x + 2
Radical degreeChange the degree of the radical by setting the Degree propertyV = Symbol("V", "Volume");Cube = Paragraph { "The edge of a cube of volume "; V; " is given by "; Radical { V; Degree: 3; };};The edge of a cube of volume V is given by V3
Nary formatterThe Nary is the most complex formatter covering a wide variety of math expressions. NaryComponents = Nary { Operator: "Operator"; PreUpper: "pre-upper"; PreLower: "pre-lower"; Upper: "upper"; Lower: "lower"; "[Body Elements]";};[Body Elements]Operatorpre-upperpre-lowerupperlower
Nary Operator propertySet the Operator property to one of the built-in symbols appropriate for your expression. s = Symbol("s", "Zeta argument (complex number)");n = Symbol("n", "Integer");ZetaSum = Nary { Operator: Tex.sum; TextStacked: true; Fraction {1; n^s};};1ns
Nary Upper PropertyUse the Upper and Lower properties to set the superscript and subscript of the Operator. InverseSquareIntegral = Paragraph { TextEquation: true; Symbol("f"); "("; x; ")"; Tex.Equals; Nary { Operator: Tex.Integral1; Upper: Tex.infty; Lower: x Tex.Equals 1; }; Fraction { 1; x^2; }; Tex.nbsp; Tex.derivative; x;};f(x) = x=11x2 dx
TextStacked propertyPlace the superscripts and subscripts above and below the Operator by setting the TextStacked property to true. StackedNary = InverseSquareIntegral { TextStacked: true;};f(x) = x=11x2 dx
Nary PreUpper and PreLowerUse PreUpper and PreLower to specify the operator prefixes. Isotope(weight, element, name) = Nary { PreUpper: weight; PreLower: element; Operator: HBox {Margin: PadL(0.1%); TextHeight: 150%; name};};Thorium232 = Isotope(232, 90, "Th");Th23290
Nary ElementsThe child elements of an Nary formatter are shown to the right of the Operator. p = Symbol("p", "Prime number");ZetaProduct = Nary { TextStacked: true; Operator: Tex.prod; Fraction { p^s; p^s - 1; };};psps − 1
TextEquation propertyIf you set the TextEquation property to true, the math font is used for all of the symbols, and the expression will stay together across line breaks. LineEquation = Paragraph { TextEquation: true; TextStacked: true;};ZetaEquivalence = LineEquation { Tex.zeta; "("; s; ")"; Tex.Equals; ZetaSum; Tex.Equals; ZetaProduct;};ζ(s) = 1ns = psps − 1
Polynomial EquationsHere is an example of a loop inside a revision, to generate a combination of polynomial terms. Polynomial(int degree) = LineEquation { for (var i = degree; i >= 0; --i) { Symbol('a' + (degree - i)); if (i > 0) { x^i; Tex.Plus; } }};FifthDegree = Polynomial(5);ax5 + bx4 + cx3 + dx2 + ex + f
Bracket PropertyUse the Bracket property to wrap an expression in scaled brackets. Term(index) = Fraction {x^index; index; Tex.factorial};Series = HBox { Bracket: Brackets.Round; Separator: Tex.Plus; LastSeparator: Tex.Plus Tex.cdots Tex.Plus; 1; Term(each [1, 2, 3, n]); // A term for each item in the array};EulerNumber = LineEquation { Symbolic.E^x; Tex.Equals; Nary { Operator: Tex.lim; Lower: n Tex.rightarrow Tex.infty; }; Series;};ex = limn→∞1 + x1! + x22! + x33! +  + xnn!
Bracket StylesChoose from a wide variety of arrow and bracket styles. VerticalBrackets = HBox { Separation: 20; VBox {Bracket: Brackets.RightArrow.Over; "Over"}; VBox {Bracket: Brackets.RightArrow.Under; "Under"}; VBox {Bracket: Brackets.Bar.Top; "bar above"}; VBox {Bracket: Brackets.FlatCurly.Bottom; "flat curly below"}; VBox {Bracket: Brackets.Round.Top; "round above"};};OverUnderbar aboveflat curly belowround above
Large expressions in BracketsEnclose large expressions in horizontal or vertical brackets. BracketEnclosure = HBox { Bracket: Brackets.FlatRound.TopBottom; Separation: 24pt; VAlign: Center; HBox {Bracket: Brackets.Round; "parenthesis"}; HBox {Bracket: Brackets.Square; "square brackets"}; VBox { Bracket: Brackets.FlatCurly.Left; "Topic {0}"(each 1..3); };};(parenthesis)[square brackets]Topic 1Topic 2Topic 3
All Bracket TypesHere is a complete list of the bracket types. TestAllBrackets = Paragraph { Separator: Space*4; foreach (var b in attribute Brackets) { HBox { Bracket: new BracketGroup(b.Value, null, b.Value, null); VBox { Bracket: new BracketGroup(null, b.Value, null, b.Value); NytrilStyle.PropName(b); }; }; }};None Angle Bar Curly FlatCurly CurvedAngle Round FlatRound Square Tortoise DoubleAngle DoubleBar DoubleRound DoubleSquare DoubleTortoise RightArrow LeftArrow RightHarp LeftHarp
Directional Bracket PlacementUse the directional member of a bracket to place arrows in specific locations. Decay(type) = VBox(null, null, PadLR(6pt)) { Bracket: Brackets.RightArrow.Under; Margin: PadLR(4pt); VAlignment: Top; HAlign: Center; Span {Space*2; type; Space*2};};ThoriumDecay = HBox { VAlign: Center; Thorium232; Decay(Tex.alpha); Isotope(228, 88, "Ra"); Decay(Tex.beta sup Tex.Minus); Isotope(228, 89, "Ac");};Th23290 α Ra22888 β Ac22889
MatricesMatrices are created with the MatrixBox formatter. They contain a list of rows and cells automatically sized to fit the contents.PlainMatrix = MatrixBox { VAlign: Center; HAlign: Center; ColumnGap: 6pt; Row {1; Fraction {Tex.pi; 2}; 3}; Row {4; 1; Symbolic.Sqrt(x+2)}; Row {y + 5; 8; 1}};WithBraces = HBox { Separation: 16pt; PlainMatrix; PlainMatrix {Bracket: Brackets.FlatRound}; PlainMatrix {Bracket: Brackets.Square};};1π2341x + 2y + 5811π2341x + 2y + 5811π2341x + 2y + 581