RaisinSecure · 2022-10-02 16:31
init.el: https://paste.sr.ht/~p00f/561c22b96b1660de2409fbdc7e128f3b20edc9fa
Math templates don't work in cdlatex mode - for example when I have `$fr$` (or `fr` in `\begin{math}...\end{math}`) and press tab when the cursor is after `r`, it doesn't expand to `\frac{}{}`.
I tried this in both `org-cdlatex-mode` and `.tex` files. Things marked as `TEXT` or `TEXT/MATH` in `org-cdlatex-command-help` work, the ones marked as `MATH` don't - pressing tab just moves the cursor out of the math environment
What's wrong?
Edit: solved by installing auctex
titanofold · 2022-10-02 17:09
You need to turn on cdlatex. Here's what I use:
(use-package cdlatex
:hook ((LaTeX-mode . turn-on-cdlatex)
(org-mode . turn-on-org-cdlatex)
(cdlatex-tab . LaTeX-indent-line)))
The `(cdlatex-tab . LaTeX-indent-line)` takes care of indenting after cdlatex does its stuff.
RaisinSecure · 2022-10-02 17:14
I turn on cdlatex for specific buffers using `M-x org-cdlatex-mode RET` for org and `M-x cdlatex-mode RET` for plain .tex, is that not enough? Note that non-math templates like `ct<TAB>` for `\cite{}` work, only math templates like `sq<TAB>` for `\sqrt{}` don't even though they are in a math environment like `$...$` or `\begin{math}...\end{math}`
Adding only the last hook gives me
cdlatex-tab: Autoloading file /home/username/.config/emacs/straight/build/cdlatex/cdlatex.elc failed to define function LaTeX-indent-line [5 times]
Edit: I get that error even after adding the other two hooks and doing `M-x straight-rebuild-package RET cdlatex RET`
titanofold · 2022-10-02 18:54
That's probably a function exclusive to AUCTeX.
I seem to remember strange behavior with cdlatex when some packages got updated, but Emacs hasn't been restarted. When's the last time you restarted Emacs?
RaisinSecure · 2022-10-02 19:53
Yep, it was because I hadn't installed auctex 😅. I saw
> You need to install ‘cdlatex.el’ and ‘texmathp.el’ (the latter comes also with AUCTeX)
on https://orgmode.org/manual/CDLaTeX-mode.html
but read somewhere that texmathp.el is built into emacs 21.3 onwards (clearly that was wrong)