I have a small problem with the package currfile and the command \currfileabspath. When compiling the file using (pdf|xe)latex I get the expected result, but if I use lualatex it adds ./ to the absolute path of the file. I'm using TeXLive 2018 (updated) in Fedora 29, the working directory looks like this:

[pablo@fedora forum] $ pwd
[pablo@fedora forum] $ ls -lha
total 12K
drwxrwxr-x.  2 pablo pablo 4,0K feb 17 13:11 .
drwx------. 43 pablo pablo 4,0K feb 17 13:10 ..
-rw-rw-r--.  1 pablo pablo  187 feb 17 13:03 test.tex

My MWE (test.tex) is this:

\texttt{\jobname.pdf} created from file \texttt{\currfileabspath}%

I use the following line to compile it:

$ pdflatex -recorder test.tex

with which I obtain:

test.pdf created from file /home/pablo/forum/test.tex

which is correct, but if I change it to:

$ lualatex -recorder test.tex

I get

test.pdf created from file /home/pablo/forum/./test.tex

How can I solve this? regards

  • 1
    It is easy to remove the ./ e.g. with a regex from expl3, but imho the best would be a feature request to the author of currfile. Feb 17 '19 at 17:01
  • @UlrikeFischer In my mind I think it's a "bug", remove the . / is an option :) , I'll try something using l3regex, thanks. Feb 17 '19 at 17:16

Removing the period is easy:

\texttt{\jobname.pdf} created from file 

But imho it would be better if currfile would do this, when lualatex is used, as the period and the slash is also in other commands.


You can easily get the absolute path in LuaTeX using the FFI and a platform-dependent function. On POSIX-based systems you can use the realpath() function, on Windows you would use _fullpath (I think).

Because it uses the FFI you have to enable --shell-escape.

In tex.sprint I use the first argument -2 to switch to verbatim catcodes, in case the path contains any characters which are treated special by TeX, such as {}$%#.

local ffi = assert(require"ffi")

char *realpath(const char *path, char *resolved_path);

function realpath(path)
    return ffi.string(ffi.C.realpath(path, ffi.NULL))

  \directlua{tex.sprint(-2, realpath(status.filename))}%


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.