Formula editor

A formula is typed as tokens, built into structures as LaTeX writes them, and read as mathematics as you type. This page says how typing makes a formula, which characters the notation reads, and how to choose what a part of a formula means.

Tokens

What you type goes into tokens. When a token has not been given a kind of its own from the lens, its kind follows the text it begins with:

A space separates tokens without writing a visible space in the formula. For example, a + b is a reliable way to write a sum, while x2 can be one name. Parentheses stand on their own, so f(x) includes separate parenthesis tokens. The editor distinguishes names, numbers and operators while typing; when a formula does not read as expected, use Split, Join or a token-kind command to correct its presentation.

A part selected, with ⌥↑ or a double click, has a lens under it that says what it is and changes its tokens: Read as a name, Read as a number, Read as an operator and Read as words change what a token is; Join makes several tokens one; and Split cuts a token into its characters, as a name into its letters. The lens also has Read aloud, ⌥R (Alt+R off Apple devices), which says the part in words where the browser can speak, and Stop while it does; and Copy as LaTeX, ⌥T (Alt+T), which copies the part as LaTeX.

Structures

Fractions and roots come from their LaTeX names, typed as a symbol’s name is: \frac writes a fraction, \sqrt a square root, and \sqrt[ an nth root. Their arguments are then read as LaTeX reads them, each in braces, in parentheses, which stay, or one character or name: \frac{1}{2} and \frac12 are both a half, \sqrt n is the square root of n, \sqrt[3]{x} a cube root, and \frac(a+b)2 is a+b over 2, its parentheses kept. While you type them, the line under the formula says which one you’re typing and what ends it. The reading ends after the last argument, at Esc, or at anything else that moves or changes the formula, such as an arrow, Tab, a click or a paste, which then does what it always does. Backspace inside an argument keeps it. Undo brings it back as it was before what Undo takes back, and Redo as it was after what Redo puts back. A brace typed anywhere else is written as itself, as a set’s is, and in an argument a set’s braces are \{ and \}, as in LaTeX.

A proof by induction comes from a name of its own: \induction writes an induction on a natural number, and \pathinduction a path induction. Each takes its arguments as \frac does, one a line, starting with the base case or the case of reflexivity, and up and down move between its lines. The notation reference says what each argument is.

Typed ^ and _ write a superscript and a subscript, and their argument is read as a structure’s is. So x^2 is x squared, x^{n+1} is x to the n+1, x^23 is x squared and then 3, x^* is x star, x^\alpha is x to the alpha, and f^(n) is f with (n) over it. Each is a script of its own, so x_1^2 is a subscript and then a superscript, the square of x₁. In text, ^ and _ are written as themselves, and anywhere else \^ and \_ write them, so x\_1 is the one name x_1. A structure’s name and a typed script put the structure at the caret, or around what is selected. Tab and Shift+Tab move between its slots. A superscript or a subscript goes on what comes just before it.

In Chrome, Edge or another Chromium-based browser, a formula, or a part of one, keeps its structures when copied and pasted into a formula. Pasted into another browser or another app, it arrives as its text, such as x^2 for x².

Characters the notation reads

Several characters look alike, and the notation reads one of each:

  • 𝟎 and 𝟏 (U+1D7CE and U+1D7CF), the empty type and the unit type, not the double-struck 𝟘 and 𝟙, or the digits 0 and 1;
  • 𝒰 (U+1D4B0), the universe;
  • ℕ (U+2115), the natural numbers, and ℤ (U+2124), ℚ (U+211A) and ℝ (U+211D), the integers, the rational numbers and the real numbers;
  • →, which -> also writes, ×, which * also writes, and the minus sign − (U+2212), which - also writes;
  • ∙ (U+2219), a path’s concatenation, not · (U+00B7) or ⋅ (U+22C5), which read as ×;
  • ≤ (U+2264), which <= also writes;
  • ∧ (U+2227), and;
  • ¬ (U+00AC), not.

≦ (U+2266) and ⩽ (U+2A7D) read as ≤ too, and ¬ (U+FFE2) as ¬. A formula keeps the one you wrote, though Synthetic draws ≦ and ⩽ as it draws ≤, as this page does. Japanese text writes ≤ as U+2266, which a Japanese input method gives, and so does \leqq. A PDF’s text can hold U+2A7D where LaTeX drew \leqslant. Text from Japanese tools on Windows can hold ¬ for ¬, and \hnot types it.

A number it reads is written with the digits 0 to 9: other decimal digits start a number that reads as nothing. A name is a letter followed by letters, marks, digits, underscores and primes, such as x₁ or f′. The minus sign is a math symbol, and -, the hyphen-minus (dash punctuation), reads as it, and a formula keeps the one you wrote.

What each of these means, how a formula groups and which readings can be stated are in the notation reference.

Choosing what a part means

A formula can read more than one way: A + B is a sum of types, or of numbers. The lens under the part selected says what it is, its role in what holds it, and, where it reads more than one way, which of its readings it shows, as “Reading 1 of 2”. Its Another reading and Check do what Tab and ↵ do. The line under the formula says what a key can’t do there, as “No other reading”.

  • ⌥↑, Alt+↑ off Apple devices, selects the part around the caret, or around the part selected.
  • A double click selects the part clicked, a triple click the part around it, and each click after that the part around the last.
  • ⌥↑ and clicks end at the whole formula, and ⌘A, Ctrl+A off Apple devices, selects it at once. Inside a fraction or another structure, ⌘A first selects what the caret is in, and each press after that what holds it. On a Document you own or can edit, the lens under a formula selected whole also moves it: Display on its own line for a formula in a paragraph’s words, and Place inline for a math block’s, as Documents says.
  • ⌥↓ selects the part inside the part selected, and ⌥← and ⌥→ the part before and after it.
  • In a chain, each link is a part: from c in a = b = c, ⌥↑ selects b = c, and then the chain. Two links share the side between them: a selection of it is in the link you reached it through, or else the first.
  • Tab and Shift+Tab show the part’s next reading and the one before, and the line says what each makes the part.
  • ↵ chooses the reading shown. With the caret in a math block and nothing selected, on a Document you own or can edit, it begins a block after the math block, as Documents says.
  • ⌘↵, Ctrl+↵ off Apple devices, checks the whole formula. A formula that reads one way, or whose reading is chosen, is checked at once; where its check is already open, that check shows again, with Check again where no answer came. A formula that reads more than one way shows its readings first, and Tab and ↵ choose the one to check. A reading with a variable’s name longer than 256 characters isn’t checked, and the lens says so.
  • ? asks the agent about the part selected, where a Document’s page offers it, in a card under the formula, and so does Ask in the lens. Where the agent may read the Document, or it’s yours and you haven’t said whether the agent may, the card asks; elsewhere it says why it can’t ask. On a part you asked about before, Ask in the lens becomes Open your question about it, or Open your earlier question about it once that question has ended, and ? opens that question. In a formula that doesn’t read, ? is refused, as ↵ is, and the line says why. With nothing selected, or where the page doesn’t offer it, ? types as any other character does.
  • Esc goes back to the reading the formula had, and puts the caret back where the selection began.

A reading is chosen only of a complete formula: while something is missing, the line says to finish the formula first. An edit drops the reading chosen.

On a Document, Check all, in the bar at the top beside Share, checks its math blocks’ formulas one after another, not those in running text. Like your own check of a formula, it commits nothing: Commit in a formula’s note does that. It leaves out a formula that’s confirmed. It skips one whose check has already been answered as it stands, one Synthetic refused to check for a reason that asking again won’t change, such as a formula too large to save, and one that can’t be checked as it stands: unfinished, too large, not reading, with no reading chosen where it reads more than one way or no reading fits all its parts, or with a variable’s name longer than 256 characters. A formula whose check got no answer is checked again, and so is one refused for a reason that can change, such as a sign-in that ended or a document that was deleted. While it runs, the count of established statements, in the bar or under the title on a phone, says how far it has come, such as “Checking 1 of 2…”. A formula’s note says what came of its check while you’re in the formula, and otherwise only where it waits on you, such as a reading to say yes to, or where something couldn’t be done. A screen reader is told at the end how many it checked and skipped, and why. You can still check a formula no reading fits: ⌘↵ and ↵ check the reading you choose. Stop checking, in its place in the bar, ends it before the next formula.

Typing the characters

Type a backslash and a character’s name, as in Lean: \N for ℕ, \to for →, \x for ×, \bullet for ∙, \and for ∧, \not for ¬, \simeq for ≃, \le for ≤, \u for ↑, \McU for 𝒰, and \bf0 and \bf1 for 𝟎 and 𝟏. A style and a letter give a styled letter, so \bbR is double-struck, \McA script, \MfA fraktur and \bfA bold, and Greek letters have LaTeX’s names, such as \alpha. The line under the formula says what a name will write. On a Japanese keyboard the key marked ¥, in the backslash’s place, starts a name as the backslash does, outside kana input, which types ¥ instead. On a Mac that key types ¥, so ¥ then Esc or Space writes a yen sign, and a yen amount is ¥, Esc and the amount; elsewhere it types a backslash. A ¥ typed any other way, as ⌥Y types one on a US Mac, is a yen sign.

The name becomes its symbol at the next Space or Tab, or any character that isn’t a letter or a digit. A symbol goes where the same character typed would go, so \N) writes ℕ and ). A letter or a digit that no name goes on with ends it too, so \to2a writes →, 2 and a. One that a name goes on with stays in it, so \xi is ξ: to write × and then i, end the name first with Space or Tab. Tab also finishes a name you have only begun. Undo brings the name back to edit, Backspace takes its last character, and Esc keeps it as typed. Two backslashes write one.

A name that would give a character the notation doesn’t read converts nothing, and the line says so, and for a look-alike what to type instead: \b0, which gives 𝟘 in other tools, points to \bf0, and \equiv points to \simeq.

⌘\, Ctrl+\ off Apple devices, with the backslash key or the ¥ key in its place on a Japanese keyboard, in a formula, opens a palette that lists every character a name writes but ≦, by group, with the name to type for each. Its search finds one by its name, as \N or N, by words, as natural or script U, or by the character itself, and says what to use for a look-alike, as \b0. A character read as another finds that one: ≦ finds ≤. With ⌘\, a name you have begun, as \na, goes into the search rather than into the formula, and Esc closes the palette and gives the name back as you typed it. Choosing one writes it at the caret as typing it would, and Undo takes it back.

On a touch screen, a row of keys over the keyboard types the characters LaTeX needs at every turn, and ends with Undo, Redo and Symbols, which opens the palette.

For any other character, use your system’s own input, such as its character viewer or an input method, or copy it from Unicode and paste it into the formula.