[Tex/LaTex] Specify path to sister directory in a style file

packagespaths

I'm about to share my LaTeX document and all its accessory files in such a way that it is self-contained and ready to compile. But I can't figure out how to refer to a sister folder from a .sty file.

I have the following .tex file in the mother directory:

\documentclass{article}
\usepackage{./testfolder/testpackage}
\begin{document}
Test
\end{document}

And a .sty file called testpackage.sty in a daughter folder:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{./testfolder/testpackage}
\usepackage{libertine}
\endinput

So far, so good. But now I need to load another package from testpackage.sty, and the package I need to load is located in the sister folder relative to the folder testpackage.sty is in. So I try this:

.tex file in the mother directory:

\documentclass{article}
\usepackage{./testfolder/testpackage}
\begin{document}
Test
\lipsum[1]
\end{document}

.sty file in daughter directory 1:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{./testfolder/testpackage}
\usepackage{libertine}
\usepackage{../testfolder2/testpackage2}
\endinput

.sty file in daughter directory 2 (sister directory of directory 1):

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{../testfolder2/testpackage2}
\usepackage{lipsum}
\endinput

Trying to compile my .tex file results in this error:

LaTeX Error: File `../testfolder2/testpackage2.sty' not found.

What am I doing wrong? According to LaTeX/Modular Documents, it should be possible to use ../ to specify sister directories.

(I know there are conventions for how to illustrate directory paths, but I couldn't find anything by googling, so I gave that up for this question).

Best Answer

Based on Ulrike's comment, it should be like this:

.tex file in the mother directory:

\documentclass{article}
\usepackage{./testfolder/testpackage}
\begin{document}
Test
\lipsum[1]
\end{document}

.sty file in daughter directory 1:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{./testfolder/testpackage}
\usepackage{libertine}
\usepackage{testfolder2/testpackage2}
\endinput

.sty file in daughter directory 2:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{testfolder2/testpackage2}
\usepackage{lipsum}
\endinput
Related Question