When working with emacs+AUCTeX I would like to consider a project with one main.tex in which you have many include's. Is it possible somehow to open the included files from within the buffer where main.tex is loaded? Somehow make emacs understand that


in main.tex is a filename (with relative path) and open it either by clicking on it or hitting some keybinding when the courser is within the curly brackets?

A "bonus" question is probably the next step, that is to have some integrated "project manager" in emacs, where the included files are listed and one can browse the projects components. Does it sound reasonable? feasible? Any ideas?

  • To clarify your question you may want to provide an example setup and describe exactly what you want to happen with it.
    – N.N.
    Commented May 7, 2012 at 10:03
  • @N.N. Is it clearer? As an example think of org-mode and how you can C-c C-o a link in an org outline, and emacs opens the file/URL/etc.
    – Dror
    Commented May 7, 2012 at 10:33
  • Yes, it is clearer. I guess one could write a function to do that if there is no way to do it directly.
    – N.N.
    Commented May 7, 2012 at 11:12
  • 1
    I'm pretty sure reftex allows you to do exactly this. Let me check…
    – Seamus
    Commented May 7, 2012 at 11:46

3 Answers 3


I use find-file-at-point. It also works for #includes in C, sometimes imports in Python, URLs, etc.

(global-set-key (kbd "C-x f") 'find-file-at-point) ;; I hardly ever set the fill-column
  • A preliminary test suggest that this IS what I was looking for! Thanks!
    – Dror
    Commented May 8, 2012 at 18:13

With reftex, C-c = will open a little table of contents. Once you've compiled the document, reftex should include the section headings of included files. You can use this menu to open included files. Indeed, if you press enter on a particular section, reftex will open the included file and put the pointer at the beginning of that section.

  • I know this option, and am using it. My bad that I didn't mention it. Anyway, having this option in mind I explicitly asked about opening the included document from "within" the buffer. Once again, sorry for my sloppiness.
    – Dror
    Commented May 7, 2012 at 14:05
  • In addition, when the included file is nothing but a TikZ code, then this won't show up in the TOC generated by RefTeX. Clicking the included filename in this case should open the file with the TikZ code in another buffer.
    – Dror
    Commented May 8, 2012 at 14:18
  • Yes, refTeX is looking for sectioning commands. I guess if you put your tikz code in a figure environment with a label, refTeX would find it then (when you pressed l to make it show all the labels)
    – Seamus
    Commented May 9, 2012 at 9:31

If you have the included file with a specified TeX-master at the end, emacs/AUC-TeX automatically loads the corresponding "main.tex", too (at least with my version). Of course, this is not quite what you want, but I think it is a good idea to set the TeX-master for the child files: you can also compile them directly and emacs invoces the pdflatex on the correct main file etc.

For the "browser" thing, I use "speedbar" which gives you a list of all files in the directly (tree-like) and you can easily jump to sections/subsections etc inside the files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .