I have following example directory structure.
ArticlesWritten
- ArticleA
- - FileOnlyInArticleA.tex
- - Introduction.tex
- - main.tex
- - MainAsChapter.tex
- - RelatedWork.tex
- -
- ArticleB
- FileOnlyInArticleB.tex
- Introduction.tex
- main.tex
- MainAsChapter.tex
- RelatedWork.tex
-
thesisFiles
FileOnlyInThesis.tex
Introduction.tex
main.tex
RelatedWork.tex
ArticleA , ArticleB is article document class while thesis is book document class. main.tex is main file for directories. I input other files from this main file. They work normal as individually.
I am trying to include ArticleA and ArticleB to thesis. I added MainAsChapter.tex to ArticleA and ArticleB. MainAsChapter.tex does not contain any latex document commands except inputs.
When I try to input following command in thesis/main.
\input{Introduction}
\input{RelatedWork}
\input{FileOnlyInThesis}
\input{../ArticlesWritten/ArticleA/MainAsChapter}
last line works but input commands in ArticleA/MainAsChapter are interpreted as coming from thesis directory. It include Introduction and RelatedWork files from thesis directory and can not find for example FileOnlyInArticleA.
If I use
\input{../ArticlesWritten/ArticleA/MainAsChapter}
I get following error
! LaTeX Error: File `FileOnlyInArticleA.tex' not found.
If I use
\import{../ArticlesWritten/ArticleA/}{MainAsChapter}
I do not get any error but input commands in MainAsChapter include Introduction, RelatedWork from MainInThesis. So I get following output.
Introduction Thesis
Related Work Thesis
FileOnlyInThesis
Introduction Thesis
Related Work Thesis
FileOnlyInArticleA
Second Introduction and RelatedWork should come from ArticleA.
Manual of import mentions that
Depending on on how your TEX system 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.
Correct Usage is
\import*{../ArticlesWritten/ArticleA/}{MainAsChapter}
This gives me , expected output of
Introduction Thesis
Related Work Thesis
FileOnlyInThesis
Introduction ArticleA
Related Work ArticleA
FileOnlyInArticleA