OrgPad logo

Math and Chemistry Added to Editor

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.

Math and Chemistry Added to Editor

#update, #math, #OrgPad, #improvements, #chemistry

Inserting Math

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.

Keyboard Shortcuts

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.

LaTeX Math Commands and Symbols

For those new to LaTeX, we have prepared a list of common math symbols and commands to get you started.

All Greek letters

Need more symbols and commands? Check out this LaTeX guide. Below is a small gallery of examples from different areas of mathematics.

Arithmetic series formula with a proof

Definition of interval graphs

Column picture of a linear system

Binomial theorem with a proof

Arithmetic of limits

Normal distribution

Chemistry

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}.

How to Turn Plain Text Into Math Formulas

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 .

Copying Math

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.

Three cells with some math and chemistry

Copied into a plain text editor

Copied into an editor with formatting

Conclusions

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.