I'm writing a very long document with dozens of figures that are all generated with matplotlib and exported as pgf files. Each figure environment then looks something like


The issue is with commands such as reftex-reference (C-c )) or LaTeX-section (C-c C-s). Both of these commands are forced to parse the entire document to do things like build a TOC (reftex-reference) or check for conflicting label names (LaTeX-section). The problem is that because of all of the pgf files, this parsing sometimes takes forever.

Question: Can I somehow make AUCTeX and/or RefTeX completely ignore all .pgf files included with a \input{} statement?

1 Answer 1


Oops! A little more digging through the RefTeX manual (pdf link) revealed the variable reftex-no-include-regexps. Documentation says:

List of regular expressions to exclude certain input files from parsing. If the name of a file included via \include or \input is matched by any of the regular expressions in this list, that file is not parsed by RefTeX.

Thus, the following line in my .emacs fixed the issue:

(eval-after-load "reftex-vars"
     (add-to-list 'reftex-no-include-regexps "\\.pgf\\'")))

This add the "\\.pgf\\'" to the other entries already present by default in reftex-no-include-regexps.

  • 1
    I'd suggest to use add-to-list in place of setq, so you won't override possible future changes to the default value of reftex-no-include-regexps.
    – giordano
    May 30, 2014 at 13:40
  • I tried that initially, but got errors about reftex-no-include-regexps being undefined. I could fix this by putting the add-to-list command in the correct hook, but I wasn't sure what hook would be best. I could also add a require statement above the add-to-list, but I am under the impression that require statements are going out-of-fashion with the rise of package.el. Is there a better suggestion? May 30, 2014 at 13:53
  • 1
    I added the code directly to your answer.
    – giordano
    May 30, 2014 at 14:14
  • Worked perfectly. Thanks a ton for your help! May 30, 2014 at 21:44

You must log in to answer this question.

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