I've written some macros that randomly selects questions from a database to include on an exam. The start of my .sty file reads as follows:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{randqs}[2012/10/23 ver 0.1]
\RequirePackage{xparse}
\directlua{dofile('randqs.lua')}
It seems that in my document, when I call
\documentclass[answers]{exam}
\usepackage{randqs}
LuaTex (or whoever) is searching for randqs.lua in the directory of the .tex file rather than in the directory of the .sty file because if the .lua is in the former then it is found, while if it is in the latter then it is not. I'm guessing that dofile is not the way to go here, so my question is: how do I ensure that LuaTex (or whoever) looks for the file in the .sty directory rather than the .tex directory?
kpselibrary, e.g.dofile(kpse.find_file("randqs.lua")). – خالد حسني Oct 26 '12 at 20:43kpse.findandrequiremethods work. Is there any reason to prefer one to the other? – Scott H. Oct 26 '12 at 21:40require()looks cleaner, butkpse.find_file()might give you a bit more control on how to locate the files (LuaTeX manual gives more details on what options you can pass to it). – خالد حسني Oct 27 '12 at 22:55