2

I need to define absolute path of .tex file, and I already learned how to do it:

\edef\currfileabsdir{\directlua{tex.sprint(lfs.currentdir())}/}

What I don't know is how to include lfs library to my LuaLaTeX preamble. I used LaTeX for the few years, but I don't have not TeX nor Lua programming experience.

In this answer, I saw the code like this:

\usepackage{luacode}

\begin{luacode}
  require "lfs"
\end{luacode}

I did not tried this code yet, but even it enough to run \edef\currfileabsdir{\directlua{tex.sprint(lfs.currentdir())}/} I need some comments about solution.

MWE:

\documentclass[a4paper, twoside]{ltjsarticle}

\usepackage{luatexja-fontspec}

\edef\currfileabsdir{\directlua{tex.sprint(lfs.currentdir())}/}

\setmainjfont[
    Path          = \currfileabsdir,
    UprightFont   = fonts/HGS_Mincho/HGRMB.ttc,
    BoldFont      = fonts/HGS_Mincho/HGRME.ttc
]{nishiki-teki}

\begin{document}
  done
\end{document}
3

The lfs library is available out-of-the-box in LuaTeX. As such, you do not need to do anything special: it will 'just work'. A very minimal demo for both plain LuaTeX and LuaLaTeX:

\directlua{print(lfs.currentdir())}
\csname @@end\endcsname
\end
  • Thank you for the answer! Accept and vote-up. – Gurebu Bokofu Mar 29 at 0:28

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.