0

I'm currently trying to transition my personal research writing from straight LaTeX to Rmarkdown to allow me to do better reproducible research, and I've run into one little snag.

Currently I have this in my init.el:

(eval-after-load 'reftex-vars
  '(progn
     ;; (also some other reftex-related customizations)
     (setq reftex-cite-format
           '((?\C-m . "\\cite[]{%l}")
             (?f . "\\footcite[][]{%l}")
             (?a . "\\autocite[]{%l}")
             (?t . "\\textcite[]{%l}")
             (?p . "\\parencite[]{%l}")
             (?o . "\\citepr[]{%l}")
             (?n . "\\nocite{%l}")))))

I know I can add lines for Rmd-style citations ([@%l]), but I would like to be able to have the list of potential citation types be context-sensitive. Is there a way to customize reftex-cite-format based on the buffer I'm currently editing, so that I can see the LaTeX-style cites in .tex files, and the Rmd-style cites in .Rmd files?

1

Maybe you can use a mode hook function to set buffer-local variables. e.g. use setq-local in the hook function. Here is an example of customizing it for org-mode.

(add-hook 'org-mode-hook (lambda () 
               (setq-local reftex-cite-format
                       '((?\C-m . "cite:%l")
                     (?f . "footcite:%l")
                     (?a . "autocite:%l")
                     (?t . "textcite:%l")
                     (?p . "parencite:%l")
                     (?o . "citepr:%l")
                     (?n . "nocite:%l")))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.