Reputation: 33
The org-cdlatex-mode helps to insert math latex symbols/tempelates in org-mode.
I would like to add some extra symbols/accents to it. I realized that the math accents are stored in the variable cdlatex-math-modify-alist-comb
and if I add to that list in the scrach buffer, I will get the extra short key for the new symbol, for example running:
(add-to-list 'cdlatex-math-modify-alist-comb '(?o "\\operatorname" nil t t nil))
works as expected. However if I add the same line in the init file, the new key won't be added to the list and emacs complains with warning that the list variable is free!
I probably need to add to the list after it has been loaded, however I couldn't find any source of how to do it.
Upvotes: 1
Views: 900
Reputation: 21
The workaround I did is to create a function that adds them every time I call my math minor mode
(define-minor-mode org-math-mode
"Some config to write math on `org-mode'."
:lighter "org-math-mode"
(org-fragtog-mode 1)
(org-cdlatex-mode 1)
(lauremacs-cdlatex-add-math-symbols))
(defun lauremacs-cdlatex-add-math-symbols ()
(add-multiple-into-list
'cdlatex-math-symbol-alist-comb
'(
(?. "\\cdot" "\\dots")
(?\; "\\;")
(?C "" "\\mathbb{C}" "\\arccos")
(?N "\\nabla" "\\mathbb{N}" "\\exp")
(?Q "\\Theta" "\\mathbb{Q}")
(?R "\\Re" "\\mathbb{R}")
(?Z "" "\\mathbb{Z}")
)))
where add to multiple is just a helper function that uses add-to-list
(defun add-multiple-into-list (lst items)
"Add each item from ITEMS into LST."
(throw-unless (symbolp lst) "List should be a symbol.")
(dolist (item items)
(add-to-list lst item)))
This might lead to a very big 'cdlatex-math-symbol-alist-comb
but it didn't bothered me yet, a solution to this is adding to list if element is not there or something like this
Upvotes: 2
Reputation: 470
Just edit cdlatex.el and compile it. For example, I add sum
with this piece of code:
("sum" "Insert \\sum_{i=1}{n}"
"\\sum_{i=1}{n}?" cdlatex-position-cursor nil nil t)
and it works.
Upvotes: 0
Reputation: 1389
The variable that needs to be set in your case is cdlatex-math-modify-alist
. The documentation of that variable says: Any entries in this variable will be added to the default.
Upvotes: 1