On Sun, Apr 13 2025, Karthik Chikmagalur <karthikchikmaga...@gmail.com> wrote:
>>> Q: Why does `org-latex-preview' not work on blocks like: >>> >>> #+begin_export latex >>> \begin{equation} >>> x^2 + y^2 = z^2 >>> \end{equation} >>> #+end_export >>> >>> I use these blocks to take advantage of syntax highlighting (and it is >>> quicker to write than not including the export block around the latex). >>> >>> Shouldn't `org-latex-preview' work on such blocks? >> >> Maybe. I do not see why not. >> Karthik, what do you think? > > org-latex-preview only previews Org elements of type `latex-fragment' or > `latex-environment'. Export blocks are not elements of this type, so > they are skipped. This is consistent with the current behavior of > org-latex-preview. I don't see why latex export blocks are not also include. > >>> I use these blocks to take advantage of syntax highlighting > > For syntax highlighting in LaTeX environments you can use > > (setq org-highlight-latex-and-related '(native)) Ok, thanks, that works nicely. Why isn't that the default? > >>> (and it is quicker to write than not including the export block >>> around the latex). > > I don't understand how this can be faster if it involves typing more > text. Could you explain? Due to various conveniences, it means typing about 2/3 less. Consider C-c C-, l ;; insert a latex export block C-c C-' ;; open an editing buffer C-c C-e ;; select an environment al TAB * RET versus \begin{align*} ;; insert literal text \end{align*} ;; insert literal test C-p ;; back-up a line C-c C-' ;; enter edit buffer By my count, the first costs 12 combined keystrokes and the second costs 27+3=30. Now that you have asked me to explain, I realized that I could: - define a bunch of abbreviations for the most commonly-used environments and save even more typing; or - simply type M-x latex-in-b RET al TAB * RET which would cost 17 keystrokes; or - play around with keymaps so that I access the `latex-insert-block'. So this observation is really about my work-style, and why I prefer to use export latex blocks. The question about why export latex blocks are not available for preview remains. Leo