1

As mentioned in my last question i have problems with \input command and relative paths which getting wrong. I also tried the import-package but don't get this to work.

Till now I just have two shared preambles at different locations so each file can find it, but it is not so great when having to edit two files.

Is there may a function in tex that I give it a root folder and just let tex search inside this folder for a specific file (tikz_packages.tex for example) and so don't have to argue with the problem with the relative paths.

Or another option may be give him two paths. When he can't find the first path he should just use the second path, then the third path till he find it.

If I get it correct there is some command like this which first look in the first path, then the seconde and so on but only for graphics:

\graphicspath{{figures/}{../figures/}{C:/Users/me/Documents/project/figures/}}

Is something like this possible in latex? Since my folder is not so big the searching should not take much time.

Many thanks.

SRel
  • 1,313

2 Answers2

1

When I have files that should be found from various locations and from various other files I normally put them in the standard search path of my tex system(s).

Sometimes I put them in texmf-local, but for many projects this is often a project specific texmf tree. The files are then e.g. in

    project-texmf/tex/latex/....

The tree is activated with (in a current texlive, miktex has an equivalent command) with

    tlmgr conf auxtrees add path/to/project-texmf

This avoids a lot hassle with relative input pathes, but it requires that the files have across all my texmf trees unique names. So generic names like "bibliography.bib" or "mypackages.tex" should better be avoided.

Ulrike Fischer
  • 327,261
1

Okay I don't know excatly why but i made a MWE and try using the import-package again and it seems to work now oO.

My MWE:

folder structure:

Path_test/main.tex
         /images/image.tex
         /preamble/packages.tex
                   -tikz_packages.tex

main.tex:

\documentclass{scrbook}
\usepackage{import}
\begin{document}
\input{preamble/packages.tex}  %% works
\input{"C:/Users/xxx/Google Drive/WS_1819/path_test/preamble/packages.tex"} %% works
\input{images/image.tex}  %% don't work
\subimport{images/}{image.tex}  %% work
\end{document}  

image.tex:

\input{../preamble/tikz_packages.tex}

tikz_packages.tex:

I am in tikz_packages
SRel
  • 1,313