27.09.2024 – Pavel Klavík, Kamila Klavíková
If you like math or chemistry, you will love this change. You can now easily insert math formulas and chemistry equations into OrgPad cells. Type in any LaTeX code, and the formula will be automatically rendered in the cell as an image.
#update, #math, #OrgPad, #improvements, #chemistry
Adding math into OrgPad is super easy. Just click the green plus button and select “Math / Chemistry.” At the bottom, just type the LaTeX code for your formula, and you'll see it appear as you type. For example, we can insert the well-known formula for arithmetic series as follows:
You can also insert a block formula, which is placed on a standalone line. It is also formatted as slightly larger; for example, indexes are placed above and below the sum symbol instead of behind it. For example, the formula for arithmetic series looks like this in block format:
To switch a formula between block and inline mode, just click the button on the left while editing.
You don’t need a mouse to work with math in OrgPad. Everything can be done from your keyboard.
To insert a new formula, use CTRL+M or CTRL+U on Windows / Linux, and CMD+U on MacOS. It will create a new formula and automatically move the cursor into its LaTeX code field. When you are done typing, just press ENTER to continue writing right after the formula.
A new block formula can be inserted directly by pressing SHIFT+CTRL+M/U or SHIFT+CMD+U. An existing inline formula can be switched to block one by pressing SHIFT+CTRL+M/U or SHIFT+CMD+U and back to inline mode by CTRL+M/U or CMD+U.
If you want to edit an existing formula, move your cursor to the right and then press SHIFT+←. Your cursor jumps at the end of its source field.
For those new to LaTeX, we have prepared a list of common math symbols and commands to get you started.
a+2b-c becomes +, -, <, >, and = directly. Use \le, \ge, and \ne to write \infty. Operators \times and \pm. Multiplication · can be inserted by \cdot.() and []. To insert curly brackets, you cannot use {} directly since it is used for grouping in LaTeX. Instead, you have to escape them as \{ and \}. For example, \{1,\dots,n\} inserts _ and superscripts with ^. To insert multiple characters, surround them by the group {}. For example, a_{i,j}^2 renders as \cdots and for bottom dots …, use \dots. For example, a_1,a_2,\dots,a_n results in b_1+b_2+\cdots+b_n becomes \frac{a}{b} or {a \over b}. To write a/b. For a binomial coefficient \binom{n}{k} or {n \choose k}.\wedge for \vee for \neg for \implies and equivalence \iff (if and only if). Quantifiers \forall and \exists.x \in A, the intersection A \cap B, the union A \cup B, the difference A \setminus B. The number sets \mathbb N, \mathbb Z, \mathbb Q, and \mathbb R. The empty set \emptyset.\ and their names, for example \alpha or \beta for \Gamma instead of \gamma. See the full list:\sum_{i=1}^\infty where indexes are specified by subscripts and superscripts. Similarly, \prod is a product n! = \prod_{k=1}^n k gives \sqrt{x^2+1}. For other roots, its degree is written is square brackets, so for example \sqrt[3]{64} = 4. \leftarrow and \to to write f : \mathbb R \to \mathbb R inserts sin, it is rendered as \sin, \cos, \tan, \cot, \exp, \log, and \ln to write these functions as \sin^2 x + \cos^2 x = 1 becomes \min and \max renders ‘ to a function, for example f’(x) and f''(x) result in \int_0^\infty e^x dx. And \lim_{n \to \infty} \sqrt[n]{n} = 1 gives a limit \vec u. Bold vectors \boldsymbol u. For example, a linear system A \boldsymbol x = \boldsymbol b.\begin{pmatrix} a & b \\ c & d \end{pmatrix}, where elements on a line are separated by & and lines are separated by \\. To write a matrix with square brackets bmatrix instead of pmatrix.Need more symbols and commands? Check out this LaTeX guide. Below is a small gallery of examples from different areas of mathematics.
If you're interested in chemistry, you can switch from math mode to chemistry mode at the bottom of the editor. In this mode, you can type chemical formulas and reactions, and they will be automatically formatted for you.
No need to learn any new symbols—just type the formulas as you normally would, and the editor will take care of the rest. For more details, you can check the cheat sheet for the mhchem package which OrgPad uses to format the formulas.
Here’s an example of the reversible transformation between gypsum (calcium sulfate dihydrate) and plaster of Paris (its hemihydrate form). When you type CaSO4.2H2O <=> CaSO4.1/2H2O + 3/2H2O, the editor will format it into the correct chemical equation for you:
You can write subscripts and coefficients as a plain text; they will be formatted correctly. Fractions also work. Use -> for a forward reaction and <=> for a reversible one. If you need to indicate a hydrate, you can use a period . or an asterisk * between the compound and the water molecules.
Auto-detection might not work perfectly, especially for charges. For example, if you want to write the chromate ion as , typing
CrO42- does not work and displays . Instead, use
^ for superscripts and _ for subscripts. So, to write the chromate ion, you would type CrO4^2-. You can also write isotopes this way: ^14_6C becomes .
In some cases, you might need to include math expressions within a chemical equation. To do this, place the math expression between dollar signs $…$ inside the equation.
For example, if a compound breaks down into
and an unknown number
of water molecules, you can type
A -> B + $n$H2O. Here, $n$ is treated as a mathematical variable within the chemical equation. You get .
Conversely, if you need to include chemical formulas inside math expressions, use the command \ce{…}. For example, the synthesis of ammonia () from nitrogen (
) and hydrogen (
) gases is shown by this balanced chemical equation
. Now, if you want to express the equilibrium constant
for this reaction, you would write:
In math mode, this is written as K = \frac{[\ce{NH3}]^2}{[\ce{N2}] \times [\ce{H2}]^3}.
If you select some text in the editor and insert math with (SHIFT+)CTRL+M/U or (SHIFT)+CMD+U, the selected text becomes its initial LaTeX source. This is useful if you already have some math inserted as plain text and want to turn it into new LaTeX math formulas.
For example, you can just write a_1,a_2,...,a_n, select it and turn it into while b_1+b_2+***+b_n turns into
.
You can copy math formulas just like any other content in OrgPad. Whether you’re copying within one document or between different documents, the formulas can be edited independently.
You can also copy formulas outside of OrgPad. When you do, they’re exported in plain text (with formulas wrapped in $…$ and $$…$$) and HTML (as SVG images). Below we show an example of three cells with some math and chemistry, copied to a plain text editor and an editor with formatting. This makes it easy to use your work in papers, websites, or anywhere else.
Your formulas are displayed and stored as SVG images and visible to everyone viewing the document. These SVG images are generated on OrgPad servers, using the Mathjax library. Missing a package? Let us know, and we might be able to add it.
We want to thank Honza Šuráň for helping to put this change together, especially spending a lot of time playing with math editor UI. As always, let us know what you think of this change and if you run into any issues. We have some further ideas and improvements, we want to implement down the road. You can also check out this YouTube video where we showcase this change.