LaTeX Color Sync

approved

by lunevoilee

This plugin has not been manually reviewed by Obsidian staff. Sync LaTeX formula color with nearby markdown text color.

1 stars30 downloadsUpdated 1mo agoMIT

LaTeX Color Sync

中文说明

What This Plugin Does

LaTeX Color Sync keeps formula color aligned with nearby text color in Obsidian source mode.

It rewrites formulas to this format:

\\textcolor{#RRGGBB}{...}

Typical use case: when your heading/link/quote text has theme color, your math formula can follow the same color automatically.

Showcase

Two Ways It Works

1) Auto Sync While Typing

  • When your edit inserts a newline (\\n), the plugin auto-syncs nearby formula colors.
  • You can disable this in settings if you prefer fully manual control or work with very large notes.

2) Manual Commands

You can also trigger sync from the command palette for partial or full-document updates.

Commands

CommandWhen to useWhat it changes
Sync LaTeX Color In Selection Or Current LineYou only want to update part of a noteRewrites formulas in selected lines (or current line)
Sync LaTeX Color In Current DocumentYou want to normalize one whole noteRewrites formulas across the current note

Recommended Workflow

  1. Start with Sync LaTeX Color In Selection Or Current Line.
  2. If result is good, run Sync LaTeX Color In Current Document.
  3. If needed, press Ctrl/Cmd+Z to rollback immediately.

Settings

SettingDefaultKeep it ON if...Turn it OFF if...
LanguageAutoYou want UI to follow app languageYou want to force a fixed language
Show summary after manual commandOnYou want feedback after each runYou prefer no popups
Auto sync on newline insertionOnYou want formulas updated whenever editing inserts a newline (\\n)You edit very large files and prefer manual sync
Also process previous line on newline insertionOnYour formula is often on the line you just brokeYou want minimal auto-processing
Prefer DOM color samplingOnYou want color to follow real rendered textYour theme is very custom and fallback behaves better
Overwrite existing top-level LaTeX colorOnYou want plugin to keep formulas consistentYou want to keep manually assigned top-level colors
Skip formulas containing embedded color commandsOnYou want safe behavior for complex formulasYou intentionally want plugin to wrap those formulas too

Why Sometimes "No Changes"

If command says no changes, common reasons are:

  • No valid $...$ or $$...$$ span in target lines.
  • Formula color already matches target color.
  • Formula is in excluded region (code block, inline code, frontmatter, HTML-like block).
  • Formula contains embedded color commands and skip setting is enabled.

Compatibility

  • Obsidian >= 1.5.0
  • Desktop and mobile (isDesktopOnly: false)
  • Source mode editor (CodeMirror 6)

Known Limits

  • Formula delimiters must open and close on the same line.
  • Extremely custom macros or unusual delimiter styles may need manual edits.

Development And Packaging

You can keep source code split in src/, but release output must be a single root main.js.

  1. Install tooling:
npm install
  1. Build a production bundle:
npm run build
  1. For local development watch mode:
npm run dev

Build result:

  • Input: src/main.js (+ imported modules in src/)
  • Output: main.js at repo root (single bundled file for Obsidian release)

GitHub Actions Release Flow

This repository includes .github/workflows/release.yml:

  • Trigger: push a tag like v0.3.2 (or 0.3.2)
  • Action: install dependencies, build main.js, upload release assets
  • Uploaded files: main.js, manifest.json, styles.css

Important: the tag version must match manifest.json version exactly.

Privacy

This plugin does not send note content to external services and does not collect telemetry.

Project Files

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.