LaTeX Math is an Obsidian plugin which adds mathematical evaluation of LaTeX math blocks to your notes, using Sympy.
Evaluate LaTeX expression is bound to Alt + B in the above demo.
In general, all demo GIFs will make use of the recommended hotkeys.1
Start out by placing the cursor inside any math block. Then execute the Evaluate LaTeX expression command (or any other command from the command list). LaTeX Math will now parse the latex math block, evaluate the expression, and insert the result at the end of the math block.
Take a look at the command list for a brief overview of what this plugin can do, or see the features list for a more in-depth walkthrough of the plugin's advanced features.
Also see the documentation, which goes more in depth about the features than this README.
Below is a table of all the commands this plugin provides, along with a brief description of what it does and optionally a recommended hotkey.
| Command | Recommended Hotkey | Usage |
|---|---|---|
| Evaluate LaTeX expression | Alt + B |
Evaluate the right most expression in a relation and simplify the result. |
| Evalf LaTeX expression | Alt + F |
Evaluate expression and output decimal numbers instead of fractions in the result. |
| Expand LaTeX expression | Alt + E |
Evaluate expression and expand the result as much as possible. |
| Factor LaTeX expression | Evaluate expression and factorize the result as much as possible. | |
| Partial fraction decompose LaTeX expression | Evaluate expression and perform partial fraction decomposition on the result. | |
| Solve LaTeX expression | Alt + L |
Solve a single equation or a system of equations. Output the result in a new math block below the current one. |
| Convert units in LaTeX expression | Alt + U |
Try to convert the units in the right most expression to the user supplied one. |
| Create truth table from LaTeX expression | If selected expression is a proposition, inserts a truth table generated from the proposition. Table can be inserted as either latex or markdown. | |
| Convert LaTeX expression to Sympy | Convert entire expression to its equivalent Sympy code, and insert the result in a code block below the current math block. |
Evaluate equations in various ways using the evaluate command suite. The computed output varies, depending on the chosen command.
The entire evaluate suite consists of the following commands: Evaluate LaTeX expression, Evalf LaTeX expression, Expand LaTeX expression, Factor LaTeX expression and Partial fraction decompose LaTeX expression.
Solve equations using the Solve LaTeX expression command.
To solve a system of equations, place them in a align or cases environment, separated by latex newlines (\\).
The solution domain can be restricted for single equations in the solve equation modal, see the relevant Sympy documentation for a list of possible values.2 Restrict the solution domain of a system of equations with symbol assumptions on the free symbols.
Define values of symbols or functions using the := operator.
Only one symbol or function can be defined per math block.
Definition persistence is location-based: any math block below a definition will use it; others will ignore it. Furthermore, all definitions are reset after an lmat code block.
To undefine a symbol or function, leave the right-hand side of the := operator blank.
Denote units or physical constants in equations by surrounding them with braces {}.
LaTeX Math automatically handles conversions between units, constants and their various prefixes. See the syntax document for a list of supported units and physical constants.
Use an lmat code block to tell LaTeX Math about various assumptions it may make about specific symbols. This is used to further simplify expressions, such as roots, or limit the solution domain of equations. By default, all symbols are assumed to be complex numbers.
lmat code blocks make use of the TOML config format. To define assumptions for a symbol, assign the symbol's name to a list of assumptions LaTeX Math should make, under the symbols table. Like definitions, an lmat code block's persistence is based on its location. See below the demo GIF for a simple static lmat code block example.
Tip
Example
```lmat
[symbols]
x = [ "real", "positive" ]
y = [ "integer" ]
```
You can read more about LaTeX Math environments and the lmat code block in the docs.
See the Sympy documentation for a list of possible assumptions.
Simplify logical propositions using the evaluate commands. Truth tables can be generated from a logical proposition using the Create truth table from LaTeX expression commands.
See SYNTAX.md/Logical Operators for a list of logical operators.
Tip
Want to check if two expressions are equal?
Put an \iff in between them and upon evaluation, LaTeX Math will insert True if they are symbolically equal or otherwise False if they are not.
Quickly convert LaTeX to Sympy code to perform more advanced computations using the Convert LaTeX expression to Sympy command.
This will insert a python code block containing the equivalent Sympy code of the selected math block.
or
Press Browse in Obsidian's Options > Community plugins menu and search for LaTeX Math.
An earlier or beta version of this plugin can be installed via two methods.
- Make sure the BRAT plugin is installed in your obsidian vault.
- Run the
BRAT: Plugins: Add a beta plugin for testing (with or without version)command via. the command palette. - Paste the LaTeX Math repository link (https://github.com/zarstensen/obsidian-latex-math) in the
Repositorytext field. - Select the desired version in the
versiondropdown. - Press the
Add pluginbutton.
The desired plugin version should now be installed in your vault.
- Download the
plugin.zipfile from the desired release version. - Extract it to your vault's plugin folder, commonly located at
.obsidian/plugins, relative to your vault's path.
The desired plugin version should now be installed in your vault.
See CONTRIBUTING
See LICENSE
Footnotes
-
All demo GIFs were produced with the Obsidian Latex Suite plugin installed. ↩
-
The default solution domain for single equations can be set via. The
domainkey in thesolvetable in anlmatenvironment. ↩



