reftex: Finding Files

 
 12 Finding Files
 ****************
 
 In order to find files included in a document via ‘\input’ or
 ‘\include’, RefTeX searches all directories specified in the environment
 variable ‘TEXINPUTS’.  Similarly, it will search the path specified in
 the variables ‘BIBINPUTS’ and ‘TEXBIB’ for BibTeX database files.
 
    When searching, RefTeX will also expand recursive path definitions
 (directories ending in ‘//’ or ‘!!’).  But it will only search and
 expand directories _explicitly_ given in these variables.  This may
 cause problems under the following circumstances:
 
    • Most TeX system have a default search path for both TeX files and
      BibTeX files which is defined in some setup file.  Usually this
      default path is for system files which RefTeX does not need to see.
      But if your document needs TeX files or BibTeX database files in a
      directory only given in the default search path, RefTeX will fail
      to find them.
    • Some TeX systems do not use environment variables at all in order
      to specify the search path.  Both default and user search path are
      then defined in setup files.
 
 There are three ways to solve this problem:
 
    • Specify all relevant directories explicitly in the environment
      variables.  If for some reason you don’t want to mess with the
      default variables ‘TEXINPUTS’ and ‘BIBINPUTS’, define your own
      variables and configure RefTeX to use them instead:
 
           (setq reftex-texpath-environment-variables '("MYTEXINPUTS"))
           (setq reftex-bibpath-environment-variables '("MYBIBINPUTS"))
 
    • Specify the full search path directly in RefTeX’s variables.
 
           (setq reftex-texpath-environment-variables
                 '("./inp:/home/cd/tex//:/usr/local/tex//"))
           (setq reftex-bibpath-environment-variables
                 '("/home/cd/tex/lit/"))
 
    • Some TeX systems provide stand-alone programs to do the file search
      just like TeX and BibTeX.  E.g., Thomas Esser’s ‘teTeX’ uses the
      ‘kpathsearch’ library which provides the command ‘kpsewhich’ to
      search for files.  RefTeX can be configured to use this program.
      Note that the exact syntax of the ‘kpsewhich’ command depends upon
      the version of that program.
 
           (setq reftex-use-external-file-finders t)
           (setq reftex-external-file-finders
                 '(("tex" . "kpsewhich -format=.tex %f")
                   ("bib" . "kpsewhich -format=.bib %f")))
 
    Some people like to use RefTeX with noweb files, which usually have
 the extension ‘.nw’.  In order to deal with such files, the new
 extension must be added to the list of valid extensions in the variable
 ‘reftex-file-extensions’.  When working with AUCTeX as major mode, the
 new extension must also be known to AUCTeX via the variable
 ‘TeX-file-extension’.  For example:
 
      (setq reftex-file-extensions
            '(("nw" "tex" ".tex" ".ltx") ("bib" ".bib")))
      (setq TeX-file-extensions
            '( "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))