# subimport including wrong file

I am trying to learn the import package but I find it extremely unreliable - perhaps I am missing something? One case study I tried is as follows:

Created 3 tex files:

• ./main.tex
• ./bla.tex
• ./X/bla.tex

main.tex:

\documentclass{article}
\usepackage{import}
\begin{document}
\subimport{X/}{bla.tex}
\end{document}


bla.tex

BLA


X/bla.tex

XBLA


However, when compiled, in the produced pdf I see BLA instead of XBLA as I have expected. Only when I remove the file ./bla.tex (or change its name), the correct one X/bla.tex is included and XBLA appears in the pdf.

What is going on? How can I make it work?

In my real-life case scenario with much bigger file structure, I have some common file names in each directory, such as config.tex and cannot afford making each name unique.

-

Depending on on how your TeX ystem is configured, if a file with the same name as the import file exists in the current directory or in the TEXINPUTS path, that other file will be read in preference to one in the import directory.
So, it tries to read the file from the . dir (for you MWE), finds it and includes, so, the result is "BLA".
The solution is to use the starred version: \subimport*{X/}{bla.tex}.