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).
\usepackage{testfolder2/testpackage2}– Ulrike Fischer Jun 19 '14 at 19:23\usepackage{./testfolder/testpackage}it's a syntax error that will generate a warning if\ProvidesPackageis used in the package (as it should be) the argument to\usepackageis a name not a file path (even though the latter sort of half works) the relative paths are always relative to the main input document not to the file with the \input – David Carlisle Jun 19 '14 at 19:24\usepackage{testpackage2}– David Carlisle Jun 19 '14 at 19:43usepackage+testpacakge2is used twice. Which is supposed to be replaced by\usepackage{testpackage2}? – Sverre Jun 19 '14 at 19:59bundledocand the--include="file1.sty, file2.sty"so that bundledoc creates a new and shareable file that includes the important.styfiles in it via thefilecontentsenvironment. This will (probably) be more portable across time, space, and different file directory structures. – jon Jun 20 '14 at 02:15