image.nvim icon indicating copy to clipboard operation
image.nvim copied to clipboard

feature:could this support latex?

Open dirichy opened this issue 1 year ago • 9 comments

I want to let this support some latex code, such as \includegraphic, is it possible?

dirichy avatar Jun 29 '24 16:06 dirichy

Hey, it could through an integration, no built-in support for that.

3rd avatar Jun 29 '24 16:06 3rd

is there some example? I want to use this in latex. Thank you for your resposing.

dirichy avatar Jun 30 '24 03:06 dirichy

Hey, the integrations are here: https://github.com/3rd/image.nvim/tree/master/lua/image/integrations Do you want it inside .tex files or something like markdown blocks?

3rd avatar Jun 30 '24 11:06 3rd

Automatic preview of math blocks in markdown would be SO nice... I wiil take a look at the integrations. Vaisakhkm2625/hologram-math-preview.nvim can be a nice inspiration too.

dubrayn avatar Sep 12 '24 07:09 dubrayn

@3rd I'm also interested

Do you want it inside .tex files or something like markdown blocks?

I would like to see my math formulas rendered while I edit markdown files. Like:

Content of "mymarkdownfile.md":

$$a_k = \text{argmax}_{a_k}  \sum_{o_k, r_k} \dots \max_{a_m} \sum_{o_m, r_m} [ r_k + \dots r_m ] \sum_{ q : U(q, a_1, \dots, a_m) = (o_k, r_k, \dots o_m, r_m ) } 2^{-l(p)}$$

And it displays the formula under the formula or when I hover my cursor over it. Thanks!

artkpv avatar Nov 05 '24 04:11 artkpv

A recent plugin started implementing LaTeX preview for markdown files. Another one can render latex blocks on demand.

dubrayn avatar Nov 05 '24 08:11 dubrayn

I think it would be something to add to https://github.com/3rd/diagram.nvim instead, keeping the built-in integrations slim. What's the best supported (and easiest to setup) way to get an image out of LaTeX source?

3rd avatar Nov 05 '24 19:11 3rd

A simple way to generate a .png file from some LaTeX content is the preview function from the python sympy module.

dubrayn avatar Nov 06 '24 17:11 dubrayn

What I did when trying to generate LaTeX some time ago was:

  • Pipe the formula into a tmp LaTeX document using the standalone document type and \Huge font
  • Compile to dvi (tex format)
  • Use dvisvgm (shipped with all latex distributions) to convert this into an svg
  • (if svg is still not imagery enough, I'd probably call inkscape next or find any library)

lquenti avatar Dec 30 '24 18:12 lquenti