Suppose i have a main repertory 'main' containing a file 'main.tex' and a child repertory named 'subfile' himself containing a file called 'subfile1.tex'. Thanks to this link https://fr.sharelatex.com/learn/Multi-file_LaTeX_projects i can write in subfile1.tex using the preambule of main.tex writing this first line in subfile1.tex :


Now i would like to create an arborescence from the main directory. Imagine i would like to create a subfolder of the repertory 'subile' called 'subsubfile' and place inside it a file called 'subsubfile1.tex'. Now i shoul write in the preambule of 'subsubfile1.tex' :


And i can continue the process... So it is boring to count each time the hierarchy and to add the corresponding number of '../' before 'main.tex'. Isn't there an automatic way of doing it ?

In fact it is not just an artificial example. I use Zim Wiki whose syntaxe create $subfolder_{ij}$ of a $folder_i$ to construct a subtopic j of a topic i. So the tree hierarchy is complex (can be quite deep) and change in the time while i am adding new child topics. But the main repertory called 'main' is always at the same absolute Path inside my dropbox folder (it is the root folder in Dropbox Folder) .

1)I first thought to place an absolute path:


but this line of code isn't recoginsed

2) Since i used my folder on different OS (linux and windows) a relative path would be better but it should

closed as unclear what you're asking by user36296, user121799, Troy, Phelype Oleinik, Stefan Pinnow Jun 6 '18 at 4:09

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Have you tried using "/Users/Eric/Dropbox/main/main.tex" as absolute path? (or use the Windows path without the single quotes, which you don't use in your relative paths – remco Apr 15 '18 at 10:32
  • Unfortunately i tried all these possibilities and it doesn't work – laurent pincemaille Apr 15 '18 at 10:49
  • On unix the full path \documentclass[/Users/Eric/Dropbox/main/main]{subfiles} works fine – user36296 Apr 15 '18 at 11:24

Browse other questions tagged or ask your own question.