# How to understand which control sequence in undefined in “Undefined control sequence.” message?

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

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}

• Your file compiles without errors for me (TL 2018). – Alan Munn Mar 29 '19 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 '19 at 1:11
• Use tex.sprint(-2,lfs.currentdir()) to switch to verbatim catcodes. – Henri Menke Mar 29 '19 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 '19 at 13:53

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

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


Has the output:

! Undefined control sequence.

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.
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())}/}

• 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 '19 at 13:55
• @GurebuBokofu You probably need another font. Try \texttt{\currfileabsdir}. – Henri Menke Mar 29 '19 at 18:55