8

I have a fairly large document, that I have picked apart into different sections etc, each in their own file. To include graphics that are not in one central directory I use \graphicspath which works quite nicely. Is there a similar command I could use to include tex files from multiple directories without me explicitly naming them?

The idea would be the following:

\graphicspath{{./Some/Directory/For/Figures1/},{./Some/Directory/For/Figures2/}}
\texpath{{./Some/Directory/For/Tex/Files1/},{./Some/Directory/For/Tex/Files2/}}

The I would like to call within the document:

\includegraphics{fig_from_Figures1}% this works
\includegraphics{fig_from_Figures2}

\input{doc_from_Files1}% this would be awesome
\input{doc_from_Files2}
Markus
  • 1,365

1 Answers1

7

The facility used by the graphics package is in fact really for tex input files, it just locally redefines the path for graphics. Just define \input@path with the same syntax:

Graphics defines

\def\graphicspath#1{\def\Ginput@path{#1}}

and then locally within \includegraphics sets

  \let\input@path\Ginput@path

so if instead you just globally defined \input@path it would affect \input{} and \read.

However for both TeX files and graphics I would probably not use this mechanism (even though I implemented it) but instead just set TEXINPUTS=.//: before running LaTeX and then all subdirectories of the current directory will be searched anyway.

David Carlisle
  • 757,742
  • Is there a particular reason you avoid these graphics and tex file path definitions? – Markus Aug 13 '13 at 18:45
  • 1
    @Markus, well mainly the kpathsea search algorithm is implemented in C and the latex input@path algorithm is implemented in TeX macros and is a gazillion times slower. – David Carlisle Aug 13 '13 at 20:45