Math Formatting
Create professionally typeset math equations using a small number of
formatting primitives.
View on YouTube
Symbols
Use 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 32
x
raised to the power of
y
is
x
y
The independent variable 'y'
Fractions
Create several different types of common fractions with the
Fraction
formatter.
FormatFraction
=
Fraction
{
x
;
y
+
1;
};
x
y
+
1
Slanted Fractions
Format the fraction with a diagonal slash by setting the diagonal argument to true.
SlantedFraction
=
Fraction
(
true
) {
x
;
y
^
2;
};
x
y
2
Compact Fractions
Create 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
3
4
of a cup of flour.
Compact Fraction Shortcut
For 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
1
2
teaspoon of sugar and stir.
TextDiagonal Property
Change 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
1
1
3
tablespoons of warm water if the dough is too firm.
Subscripts
Add a subscript to a symbol by using the
sub
operator.
X1
=
x
sub
1;
x
1
Superscripts
Use 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
=
m
c
2
The speed of light
Radicals
Square-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 degree
Change the degree of the radical by setting the
Degree
property
V
=
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
V
3
Nary formatter
The
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]
Operator
pre-upper
pre-lower
upper
lower
Nary Operator property
Set 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
};
};
1
n
s
Nary Upper Property
Use 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
=
1
1
x
2
d
x
TextStacked property
Place the superscripts and subscripts above and below the Operator by setting the
TextStacked
property to true.
StackedNary
=
InverseSquareIntegral
{
TextStacked
:
true
;
};
f
(
x
)
=
∞
x
=
1
1
x
2
d
x
Nary PreUpper and PreLower
Use
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"
);
Th
232
90
Nary Elements
The 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;
};
};
p
s
p
s
−
1
TextEquation property
If 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
)
=
1
n
s
=
p
s
p
s
−
1
Polynomial Equations
Here 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);
a
x
5
+
b
x
4
+
c
x
3
+
d
x
2
+
e
x
+
f
Bracket Property
Use 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
;
};
e
x
=
lim
n
→∞
1
+
x
1
!
+
x
2
2
!
+
x
3
3
!
+
⋯
+
x
n
n
!
Bracket Styles
Choose 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"
};
};
Over
Under
bar above
flat curly below
round above
Large expressions in Brackets
Enclose 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 1
Topic 2
Topic 3
All Bracket Types
Here 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 Placement
Use 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"
);
};
Th
232
90
α
Ra
228
88
β
−
Ac
228
89
Matrices
Matrices 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
π
2
3
4
1
x
+
2
y
+
5
8
1
1
π
2
3
4
1
x
+
2
y
+
5
8
1
1
π
2
3
4
1
x
+
2
y
+
5
8
1