I keep all my commonly used latex packages in one custom package, including the referencing package cleveref. However, reftex is configured to only provide insertion of cleveref referencing commands like cref if
\usepackage{cleveref} is in the document itself. So I wanted to re-configure reftex-ref-style-alist to provide cleveref-commands without depending on the cleveref-package in the used packages in a latex document. I used the Emacs customization buffer to not have Cleveref depend on any package, yielding
'(reftex-ref-style-alist '(("Default" t (("\\ref" 13) ("\\Ref" 82) ("\\footref" 110) ("\\pageref" 112))) ("Varioref" "varioref" (("\\vref" 118) ("\\Vref" 86) ("\\vpageref" 103))) ("Fancyref" "fancyref" (("\\fref" 102) ("\\Fref" 70))) ("Hyperref" "hyperref" (("\\autoref" 97) ("\\autopageref" 117))) ("Cleveref" t (("\\cref" 99) ("\\Cref" 67) ("\\cpageref" 100) ("\\Cpageref" 68))) ("AMSmath" "amsmath" (("\\eqref" 101))))) in my customized variables, but for whatever reason, this still doesn't lead to reftex providing the cleveref commands without cleveref called in a tex file. I also tried to put the following into my (usepackage tex) :config settings:
(eval-after-load "latex" '(TeX-add-style-hook "cleveref" (lambda () (if (boundp 'reftex-ref-style-alist) (add-to-list 'reftex-ref-style-alist '("Cleveref" t (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D))))) (reftex-ref-style-activate "Cleveref") (TeX-add-symbols '("cref" TeX-arg-ref) '("Cref" TeX-arg-ref) '("cpageref" TeX-arg-ref) '("Cpageref" TeX-arg-ref))))) Neither of these worked. Why? And how can I set reftex-cleveref-insertions to be globally available.
Edit: Interestingly, if I have
\usepackage{cleveref} in one of the .tex files in a buffer in my desktop file when I start Emacs, it seems to provide the corresponding reftex-templates globally, so in particular in files in which it is not included. However, the same isn't true if I have it in a .sty file.