| 1 |
# addtoluatexpath |
| 2 |
|
| 3 |
|
| 4 |
The `addtoluatexpath` package provides a convenient way to add input and Lua package paths to your document. |
| 5 |
You may want this package if `.cls` or `.sty` files are located outside of your tex directories (like a network drive or cloud storage drive). |
| 6 |
|
| 7 |
## Usage |
| 8 |
* You can either pass the comma-separated paths via package options like `\RequirePackage[path1,path2]{addtoluatexpath}` in pre-amble, |
| 9 |
or by using the macro `\addtoluatexpath{path1,path2}` after the package has been loaded. |
| 10 |
* If you wish to include first-level sub-directories as well as a path, inlcude a `/*` at the end of the path. |
| 11 |
eg. `\RequirePackage[C:/Users/me/Desktop/*]{addtoluatexpath}` adds your Desktop and all folders in the desktop to path. |
| 12 |
* If you wish to include all nested sub-directories of all levels, include a `/**` at the end of the path. |
| 13 |
* If you want to add to Lua path (`package.path`) only, include `notex=true` in the argument. |
| 14 |
* If you want to add to tex input path only, include `nolua=true` in the argument, eg. `\RequirePackage[nolua=true, C:/Users/me/Desktop/*, /**]{addtoluatexpath}`. |
| 15 |
* If you want to supress a package error that comes up if a directory you try to add does not exist, set `noerror=true`. |
| 16 |
* The lua table `addtoluatexpath` is globally defined with the following attributes: |
| 17 |
* `.main(paths_str)` is the main function that runs, `paths_str` is the argument to `\addtoluatexpath` or the package options. |
| 18 |
* `.paths = {'.', ...}` is a table containing all paths added by this package |
| 19 |
* `.find_file(file_str)` is a function that returns the full path of a file, it searches through all paths that were input to this package and returns the first valid. If no paths are found, an error is issued. |
| 20 |
* `.prt_paths()` prints the paths to the log file. |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
## Notes |
| 25 |
This package appends to the `package.path` Lua variable and the `\input@path` command sequence (it first uses `\providecommand` to initialize it). |
| 26 |
Lua files in the added paths can then be added via `require'fileinpath1'`; however `loadfile` and `dofile` still require the full path. Caveat: |
| 27 |
`graphicx` internally uses `\input@path` as a default list of the paths; |
| 28 |
therefore, paths specified by this package will also include graphics if the `graphicx` package is loaded _after_ paths are set. |
| 29 |
However, if `\graphicspath{}` is used after paths are added by this package, graphics search paths will not use `\input@path`, therefore not using the paths you added with this package. |
| 30 |
|
| 31 |
## Dependencies |
| 32 |
`luacode`, `luakeys`, `penlight` |
| 33 |
|
| 34 |
## Repo & Contact |
| 35 |
|
| 36 |
* <https://github.com/kalekje/addtoluatexpath> |
| 37 |
|
| 38 |
* [[email protected]](mailto:[email protected]) |
| 39 |
|
| 40 |
|
| 41 |
## License |
| 42 |
|
| 43 |
Copyright (C) 2023-2025 Kale Ewasiuk |
| 44 |
|
| 45 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 46 |
of this software and associated documentation files (the "Software"), to deal |
| 47 |
in the Software without restriction, including without limitation the rights |
| 48 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 49 |
copies of the Software, and to permit persons to whom the Software is |
| 50 |
furnished to do so, subject to the following conditions: |
| 51 |
|
| 52 |
The above copyright notice and this permission notice shall be included in |
| 53 |
all copies or substantial portions of the Software. |
| 54 |
|
| 55 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF |
| 56 |
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
| 57 |
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
| 58 |
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
| 59 |
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR |
| 60 |
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 61 |
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 62 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE |
| 63 |
OR OTHER DEALINGS IN THE SOFTWARE. |
| 64 |
|