function rust_listing (dir, subpath) local module_name = subpath:gsub(".tex$",""):gsub("mod$",""):gsub("/","::") module_name = module_name:gsub((".?"):rep(47) .. "::", "%1\\breakline{}" ) local caption = "\\texttt{" .. module_name .. "}" tex.sprint( "\\lstinputlisting[" .. "caption={" .. caption .. "}" .. "]{" .. dir .. subpath .. "}" ) end