Currently when I choose an entry from RefTex's table of contents (opened using the C-c = keybinding), if I only have a single window open, the chosen file is opened in a new window to the right of the current document. I read the documentation for reftex-toc but couldn't find a way how to replace the file of the current window when pressing the ret key instead of opening a new window.

Is this possible? If yes, can anyone be so kind to share the code how to do it?

Edit: The document I am using is a multi-file. The new section I choose is in another file than the one I am currently in. For example, if I am in main.tex and I choose the Introduction section, the file Sections/introduction.tex is opened in a new window.

The below is the settings I have in my init.el in relation to LaTeX

(use-package auctex
  :defer t
  :ensure t
  (setq TeX-auto-save t)
  (setq TeX-parse-self t)
  (setq-default TeX-master nil)
  (setq reftex-plug-into-AUCTeX t)
  ;; Set default reference format to \ref
  (setq reftex-refstyle "\\ref")) ; Set default reference format to \ref

(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
  • If I have a single window open with a LaTeX file, and call the table of contents C-c =, after I pick the heading I want to go to and press return, the table of contents disappears and I return to having a single window with the original file displayed. I think this is the behaviour you want; if so, it should be the default already! – Tyler May 3 at 18:38
  • If what @Tyler indicates is true then (1) check, by starting Emacs using emacs -Q (no init file) and (2) if that does what you want then bisect your init file to find the culprit. – Drew May 3 at 21:49
  • @Tyler do you have a multi-file project? I should have said that in the description. Let me update it. – Noel May 4 at 6:18

Your Answer

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

Browse other questions tagged or ask your own question.