Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enter enter #2

Open
aloispichler opened this issue Mar 24, 2024 · 1 comment
Open

enter enter #2

aloispichler opened this issue Mar 24, 2024 · 1 comment

Comments

@aloispichler
Copy link

aloispichler commented Mar 24, 2024

Very useful package, and clever idea, congratulation!
Here, entering a newline (with the return key, e.g.) often wipes out the formula… But this workflow is often necessary, for example with an align environment. Actually, it seems the problem occurs if the formula contains an empty line.

Just a note: other packages, for example this in orgmode only, work with MathJax. Would that be faster?

@ultronozm
Copy link
Owner

ultronozm commented Mar 24, 2024

Thanks for the kind feedback!

I think the issue you mention is that, as far as I understand, newlines are not supposed to occur in valid math environments. I'm not in the habit of introducing them myself, even in align environments, because I use abbrev expansions that avoid this (see for instance the "nal" and "cal" abbrevs in https://github.com/ultronozm/dynexp.el/blob/main/lisp/dynexp-abbrev.el).

I pushed a commit to czm-preview just now that adds a customization variable czm-preview-accomodate-newlines-in-environments, with default value t, that attempts to address the issue you mention by excising newlines before sending a region to TeX for processing. It seems to work OK (see pic). Please let me know if you have further issues.

Screenshot 2024-03-24 at 23 51 54

I'm not sure what would be fastest. The bottleneck with preview.el (and hence with this package) is how long it takes latex to compile a nearly trivial tex file into a dvi file. It seems that org-latex-preview also uses preview.sty and compilation to dvi/png, so I would have guessed it'd be comparable in speed to preview.el, but there could be other optimizations. On my laptop, the previews generate with this package in about 400 ms on average, which feels very snappy and is good enough for my practical purposes. You could make them ever so slightly snappier by decreasing the customization variable czm-preview-timer-interval (default: 0.3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants