1

I need to know what is the actual output directory, as set by the -outdir or -output-dir command line switch, because I am executing external programs and I need to give them the exact location of the auxiliary file to use, similarly to this unanswered question.

The difference is that I am using LuaLaTeX, so there might be new or easier means to get this right.

To test, I tried printing this directory in the document, but \directlua{tex.print(status.list()["output_file_name"])} only gives the basename and \directlua{tex.print(os.env["PWD"])} gives the working directory of the process which is not, as I had hoped, set to the outdir.

2

Arguments passed to luatex are stored in the lua table arguments. They are indexed by the passed key.

To find such info, you can search the _G (or more generally, _ENV) table, where all lua globals are indexed.

There is an introspection script on the lua website for this.

By the way, lua has the . syntactic sugar to refer to string keys in a table. eg : os.env["PWD"] is the same as os.env.PWD

Below I can't do this for "output-directory" because of the -.

The output

If i have compiled my file with lualatex --output-dir=myOutDir myf.tex, I get :

enter image description here

The code

\RequirePackage{luatex85}
\documentclass[12pt]{standalone}
\usepackage{luacode}
\usepackage{fourier}
\begin{luacode*}
  function passedOutputDir()
    return arguments["output-directory"] or "noPassedOutputDir"
  end
\end{luacode*}
\begin{document}
Passed output dir : 
\directlua{tex.print(passedOutputDir())}
\end{document}
  • Sounds interesting but does not work with me (lualatex v1.0.4 (TeX Live 2017)). The arguments table is empty (if this is correct). – ysalmon Aug 26 '17 at 14:49
  • @ysalmon It is empty if you don't pass arguments when compiling. Also, the output directory does not seem to be passed from latexmk to lualatex directly. – marsupilam Aug 26 '17 at 14:52
  • Of course. After further investigation, it appears that lualatex -output-dir=test mwe.tex compiles into test but arguments is empty, while lualatex --output-dir=test mwe.tex compiles to the same dir but arguments is set this time. Strange. – ysalmon Aug 26 '17 at 14:56
  • 1
    So, the following does the trick : latexmk -pdflua -outdir=build -latexoption="--output-directory=build". It is also interesting to note that lualatex seems not to complain when it is passed arbitrary options --myprivateoption=myvalue and they are accessible through arguments : one can effectively pass parameters to the script being compiled. – ysalmon Aug 26 '17 at 15:16
  • 1
    You can find all luatex arguments in the arg table... – Paul Gaborit Aug 26 '17 at 15:25

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.