I'm trying to automate pdftex to generate docs. I'm in some kind of hell where TeX assumes people want to use absolute paths or the working directory.
I have the file main.tex. It imports several files from subdirectories:
\include{one/one}
\include{two/two}
I invoke pdftex /path/to/main.tex
from another directory and tex consistently tries to import relative to the directory 'pdftex' was invoked from rather than the directory of main.tex.
I can't predict what the absolute paths will be on different machines to use those. The 'import' package would only work if I had yet another TeX file in the current working directory that knew what the absolute path to main.tex would be. Is there any way to have main.tex use relative paths without having to include absolute paths in a TeX file? I just want the file to use paths that are relative to where that file is, not relative to the working directory or the phase of the moon.
(As a minor blessing, at least none of those included TeX files needs to include other files or graphics, because that'd be its own problem.)
Best Answer
Note you should not include the
.tex
extension when using\include
Unlike\input
using.tex
is not the same as using the default, it will find the same tex file but generate a different aux fileone.tex.aux
(if the file system allows that) rather thanone.aux
.It normally works best to just use local file names rather than paths.
Just have
then use a command line of
(or equivalent in other command lines, the above works in bash)
Setting TEXINPUTS as above sets the TeX input path to be
/path/to
and all its sub-directories (the trailing//
and then the standard search path (because of the final:
) thenmain
on the command line finds/path/to/main.tex
,\include{one}
finds/path/to/main/one/one.tex
and ,\include{two}
finds/path/to/main/two/two.tex
irrespective of the current directory in which the command is run.