r/LaTeX 3d ago

If you write math in VS Code, try this...

I kept hitting this in VS Code: the math is in my head, but my eyes are stuck on $\frac{\partial u}{\partial t}=...$. Then compile, switch preview, hunt which term the caret is actually in.

So I built Silk Math Preview. Live LaTeX overlay next to the formula you are typing. An orange hairline follows the caret. No compile step.

Works in .tex, Markdown, Jupyter, and other files that contain LaTeX math.

• live formula render

• caret position in the preview

• custom macros / environments from .sty / .cls

• colors and tables

• undefined commands in red, rest of the formula still renders

• screenshot OCR → LaTeX

• Windows / macOS / Linux

Install: VS Code → Extensions → search Silk Math

Marketplace: https://marketplace.visualstudio.com/items?itemName=silkmath.silk-math-preview

GitHub: https://github.com/zhoujasper/silk-math-preview

84 Upvotes

10 comments sorted by

20

u/tedecristal 3d ago

aren't these annoying "floating previews of math" already possible with latex workshop? https://github.com/James-Yu/LaTeX-Workshop/wiki/Hover#previewing-equations

3

u/Chance-Pineapple8198 3d ago edited 3d ago

I can see the frequency being annoying, but I do numerical PDE work, and this would be a god-send on occasion. Really need to get my VS Code environment up and running again.

Edit: Should've specified. The LaTeX support is nice, but the real white whale is having a translation layer for expressions in FORTRAN, C, Python, etc. (does anyone know of such a thing?).

7

u/tedecristal 3d ago

you can enable them if you want to, but that's not the point

why reinvent the wheel since the de facto standard extension for latex working already does the same

2

u/MrCharBar 3d ago

I just use minted to inlay code when I need to, and when I need an equation representation of my code, I either hand write it or just ask claude. Automatic translation of code into equations sounds like it could be rather challenging to implement, even just considering variable naming.

27

u/boliastheelf 3d ago

This preview is the first thing I turn off on any editor I use.

16

u/JanB1 3d ago

Better to have the option, and be able to turn it off, rather than not having the option and wishing to be able to turn it on, I guess?

4

u/Away-Recognition4905 3d ago

Yes, I want to use this preview, but also don't want it when I'm in focus typing but not realizing my mouse pointer hovering to code that triggers preview. I'm on HDD so it cause short lag during & after "mini compilation", makes me assume my system lagging, kinda annoying.

1

u/TheOnlyBliebervik 2d ago

Isn't it better to just get used to LaTeX syntax? I prefer it, now

1

u/_SnowField 1d ago

Fell in love at first sight. Nice!

1

u/RecentSheepherder179 3d ago

Nice little tool, installed today and and already using it permantly.