The following question is closely related to this one but represents a scenario much closer to my real life use case, in which descendants reference their ancestors, rather than vice versa, and the main file is one of the leaves rather than the root of the file tree.
I have set up the following file tree. (It's similar to the one described in my other post, with the addition of the Sibling
branch.)
. [D] (working directory)
Test.tex [F]
SubFolder [D]
SubTest.tex [F]
SubSubFolder [D]
SubSubTest.tex [F]
SiblingFolder [D]
SiblingTest.tex [F]
To give real-life context to this file structure: The working directory is a container for all the courses I take this academic year. Each subfolder is a container for a different course. Each subsubfolder is a container for a different homework assignment or project in the associated course. And the sibling folders are for fonts, graphics, bibliographies, and other files I wish to make available universally. When I compile a homework problem, I do so from the homework problem's directory, not from the root of the file tree.
Back to the current problem. I would like to be able to navigate the file tree from one level to the other starting from SubSubTest.tex
. The desired display of the PDF file to be produced by pdflatex SubSubTest
should be:
[../../]
[../]
[]
[../../SiblingFolder/]
An Attempt
SubSubTest.tex
\documentclass{article} \usepackage{import} \import{..}{SubTest} \newcommand{\SubSubDir}{\hspace{0pt}} \begin{document} [\Dir]\par [\SubDir]\par [\SubSubDir]\par [\SiblingDir] \end{document}
SubTest.tex
\usepackage{import} \import{..}{Test} \newcommand{\SubDir}{../}
Test.tex
\import{SiblingFolder}{SiblingTest} \newcommand{\Dir}{../../}
SiblingTest.tex
\newcommand{\SiblingDir}{../../SiblingFolder/}
Executing
> cd ~/SubFolder/SubSubFolder
> pdflatex SubSubFolder
resulted in a compilation failure with the following error message.
! LaTeX Error: File `SiblingFolder/SiblingTest.tex' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: tex)
Enter file name:
! Emergency stop.
<read *>
l.1 \import{SiblingFolder}{SiblingTest}
^^M
End of file on the terminal!
How can this issue be fixed?
\subimport
instead of\import
? Though I didn't read the documentation to see what's the difference between the 2\input{SubSubTest}
or\input{SiblingTest}
from any file if you had arrangedTEXINPUTS=/path/workingdir//:
so all files in that tree are found\input{dir1/file}
and\input{dir2/file}
. But no matter, I'm sure someone will post something closer to what you ask for.