The general idea is that I can get the relative path of my project root by including the package mymacros.sty in my subprojects. I have the following setup:
- mymacros.sty
- myimg
- figure.tikz
the content of mymacros.sty looks like this:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mymacros}
\RequirePackage{xparse}
\NewExpandableDocumentCommand \projectabspath {}
{%
\directlua{tex.print(file.pathpart(file.addsuffix(file.collapsepath("\@currname"),'sty')))}%
}
I'm extracting the relative path from the \@currname macro with lua.
When I call the macro in my file figure.tikz
\documentclass{standalone}
\RequirePackage{luatex85}
\usepackage{../mymacros}
\typeout{\projectabspath}
\begin{document}
absolute path: \projectabspath
\end{document}
I get an empty path. What is the problem with my code?
\input@path. After that\usepackage{mymacros}would find it. – Marcel Krüger Aug 13 '18 at 11:53lfs.currentdir()instead of\@currnameto determine the path of mymacros.sty? – Reza Aug 15 '18 at 07:09lfs.currentdir()returns the current working directory of the TeX process. TeX never changes the working directory during a run, solfs.currentdir()always gives the directory TeX was called from. Normally this is the directory of your main document. – Marcel Krüger Aug 15 '18 at 09:10