1

I got "Undefined control sequence." message, but from ...sdir{\directlua{tex.sprint(lfs.currentdir())} I do not understand, on which control sequence LuaLaTeX refers:

enter image description here

How can I explore it?

The MWE is

\documentclass[a4paper, twoside]{ltjsarticle}

\usepackage{luatexja-fontspec}

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

\begin{document}
    done
\end{document} 
  • 1
    Your file compiles without errors for me (TL 2018). – Alan Munn Mar 29 at 0:47
  • @AlanMunn, Thank you for try. Did you compile by LuaLaTeX? It's interesting, what I missed. I'll upload a screencast later. – Gurebu Bokofu Mar 29 at 1:11
  • Use tex.sprint(-2,lfs.currentdir()) to switch to verbatim catcodes. – Henri Menke Mar 29 at 2:30
  • @HenriMenke, Thank you for the comment. Unfortunately, It will delete path separators, and C:Users/me/Documents/TeX/LuaLaTeX_Development/fonts/HGS_Mincho/HGRMB.ttc becomes to C:UsersmeDocumentsTeXLuaLaTeX_Development/fonts/HGS_Mincho/HGRMB.ttc. – Gurebu Bokofu Mar 29 at 13:53
2

The undefined control sequence is the thing just before the line break:

\documentclass{article}
\begin{document}
\quad\acommandthatdoesntexist\quad
\end{document}

Has the output:

! Undefined control sequence.
<*> \quad\acommandthatdoesntexist
                    \quad

In your case, that appears to be \Users, which may suggest that TeX is trying to read a Windows path and interpreting the \ as beginning a command. You'll probably need a package that can navigate Windows directories.

5

The undefined control sequence is \Users which is part of the path. Even though here \ is meant to be the path separator, LuaTeX doesn't know that and just feeds the path with the currently active catcodes back to TeX, where \ happens to be the escape characters. Luckily, you can tell tex.sprint to use a different catcode table using an optional argument. To use verbatim catcodes (everything is catcode 12, except space which retains catcode 10) use the catcode table with number -2.

\edef\currfileabsdir{\directlua{tex.sprint(-2, lfs.currentdir())}/}
  • That why I did not understand... You have the deep understanding. Thank you for the answer! – Gurebu Bokofu Mar 29 at 3:25
  • I checked your solution. Unfortunately, it will delete path separators, and C:Users/me/Documents/TeX/LuaLaTeX_Development/fonts/HGS_Mincho/HGRMB.ttc becomes to C:UsersmeDocumentsTeXLuaLaTeX_Development/fonts/HGS_Mincho/HGRMB.ttc. – Gurebu Bokofu Mar 29 at 13:55
  • @GurebuBokofu You probably need another font. Try \texttt{\currfileabsdir}. – Henri Menke Mar 29 at 18:55

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.