Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- latex -----------------> lua first call
- <-------- return full file name "/home/me/etc..../file_name.m"
- (full file name)
- latex -------------------> second lua call
- <---- return final result
- documentclass{article}
- IfFileExists{luatex85.sty}{usepackage{luatex85}}{}
- ifdefinedHCode% detect tex4ht
- usepackage[utf8]{luainputenc}
- usepackage[T1]{fontenc}
- else
- usepackage{fontspec}
- fi
- usepackage{luacode}
- begin{luacode*}
- require 'lfs'
- -- first LUA function
- function fullpath(curDir,fileName)
- local pathseparator = package.config:sub(1,1)
- if os.type == "windows" then
- fileName=string.gsub(fileName,"/",pathseparator)
- end
- local name=table.concat({lfs.currentdir(),fileName}, pathseparator);
- print(name)
- tex.print(name)
- end
- -- second LUA function
- function format(fileName)
- --for now, just print it.
- tex.print("\verb|"..fileName.."|")
- end
- end{luacode*}
- newcommandfullpath[2]{luadirect{fullpath(luastring,#2)}}
- newcommandformat[1]{luadirect{format(#1)}}
- begin{document}
- %ask LUA to find full path name of some file. This should work
- %on both windows and Linux
- %how to save this result in Latex?
- %fullpath{jobname.tex}{"sub_folder/foo7_1.tex"} %causes an error.
- %edef causes error
- defname{fullpath{jobname.tex}{"sub_folder/foo7_1.tex"}}
- %send the name back to lua. causes error if uncomment
- %format{name}
- end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement