LaTeX Inline Block Toggle
approvedby frank-smith
Toggle LaTeX math between inline and display blocks, and merge consecutive block formulas. - This plugin has not been manually reviewed by Obsidian staff.
LaTeX Inline Block Toggle
Repository · Releases · Changelog
Convert LaTeX math between inline ($...$) and display block ($$...$$) styles directly in the Obsidian editor.
Features
- Two editor commands:
Toggle math inline/blockMerge consecutive block formulas
- Commands are registered through Obsidian's official command system so users can set their own hotkeys.
- Both actions are available in the editor right-click context menu (configurable).
- Selection-aware behavior:
- If text is selected, conversion runs on the selection.
- Without a selection, toggle converts the block at the cursor to inline math, or all inline formulas on the current line to blocks.
- Merge combines adjacent blocks into an
alignedenvironment.
- Friendly
Noticemessages when conversion cannot be safely performed. - Settings for context menu visibility and whitespace trimming. Block output is multiline.
Demo (Text)
Block to inline
Input:
$$
\lim_{n \to \infty} a_n = L.
$$
Output:
$\lim_{n \to \infty} a_n = L.$
Inline to block
Input:
$\lim_{n \to \infty} a_n = L.$
Output (multiline block):
$$
\lim_{n \to \infty} a_n = L.
$$
Installation (Manual Sideload)
- Download
main.js,manifest.json, andstyles.cssfrom the latest release, or build the plugin (see below). - Create a folder in your vault:
.obsidian/plugins/latex-inline-block-toggle/
- Copy these files into that folder:
main.jsmanifest.jsonstyles.css
- In Obsidian:
- Open
Settings -> Community plugins - Disable Safe mode (if needed)
- Enable
LaTeX Inline Block Toggle
- Open
Compatibility
The minimum app version remains 1.5.0, on desktop and mobile. On 1.13+, the two settings use Obsidian's declarative API for settings search; older versions use the existing settings UI. Command IDs and setting keys are unchanged by the API update. External settings reload is available on 1.5.7+.
If upgrading from the old obisian-latex-inline-block-toggle ID, disable the old plugin first. Keep a copy of its data.json, install into the new folder above, and copy that file into it before enabling. The earlier ID rename changes Obsidian's command namespace, so reassign custom hotkeys to the new plugin. Do not enable both copies.
See official API references and validation notes.
Development Setup
- Clone this repository.
- Install dependencies:
npm ci
- For development watch mode:
npm run dev
- For a production build:
npm run build
Run npm run typecheck and npm test to check types and run the lightweight regression suite (no extra test dependencies).
Build Instructions
npm run dev:- Watches
main.tsand rebuildsmain.json changes.
- Watches
npm run build:- Creates a production bundle (
main.js).
- Creates a production bundle (
npm run version:- Updates
versions.jsonusingmanifest.jsonvalues.
- Updates
How Commands Work
Toggle math inline/block
Select an inline expression or a block to convert it. Without a selection, the command converts the block at the cursor to inline math; otherwise it converts inline expressions on the current line into separate multiline blocks. Block-to-inline conversion can join neighboring text lines with matching quote prefixes.
Output format
Inline-to-block conversion always places the opening and closing $$ delimiters on separate lines. For example, $formula$ becomes:
$$
formula
$$
Block-to-inline conversion flattens line breaks and produces $formula$. Existing single-line display blocks are also accepted as input:
$$ formula $$
Toggling this block produces $formula$ with the default whitespace trimming setting. Toggling it again produces the multiline block shown above. There is no setting to generate single-line display blocks.
Merge consecutive block formulas
Select consecutive blocks, or place the cursor in one of them, to merge the group into a single aligned block. Intervening text prevents merging.
Settings
Open Settings -> Community plugins -> LaTeX Inline Block Toggle:
Show commands in editor context menu(default:true)- Show/hide the conversion actions in the editor right-click menu.
Trim surrounding whitespace when converting(default:true)- Trims extracted math content during conversion.
Edge Cases and Limitations
- Inline detection is intentionally restricted to the current line.
- Escaped dollar signs (
\$) are not treated as delimiters. - The plugin distinguishes single-dollar and double-dollar delimiters.
- Heuristics are used to avoid obvious currency false positives, but not every ambiguous case can be perfectly inferred.
- Malformed or deeply ambiguous delimiter patterns are safely rejected with a notice.
- Fenced math blocks like
```mathare not supported (by design). - This plugin does not implement a full LaTeX parser.
License
MIT. See LICENSE.
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.