1

I have several folders/subdirectories (within a main directory) having a Tex projects (of their own) that require a single style file that is in the main directory.

Rather than having a copy of the style file for each subdirectory, I would like just direct TeX to the single style file I have. This will save me work, whenever I would update the style file.

Is there any way to achieve that: To usepackage from a superdirectory?

Ahmed
  • 11
  • 1
    Put that style file in your local texmf tree (for mac users, it can be /usr/local/texlive/texmf-local) and then run sudo texhash in the terminal. Then you can \usepackage it everywhere. – Stephen Dec 22 '23 at 07:01
  • 2
    See also https://tex.stackexchange.com/questions/1137/where-do-i-place-my-own-sty-or-cls-files-to-make-them-available-to-all-my-te – Stephen Dec 22 '23 at 07:07
  • @Stephen Is there a way to do it, without putting that style file into the local texmf tree? – Ahmed Dec 22 '23 at 07:12
  • 2
    You can also use relative path: \usepackage{../mypkg}. – Stephen Dec 22 '23 at 07:31
  • @Stephen Please don't - the argument to usepackage is supposed to be a file name, not a path, and TEXINPUTS or similar the expected ways to deal with this – Joseph Wright Dec 22 '23 at 08:22
  • OK. Thank you for your comment@JosephWright I just think this is a possible way but not recommend it. – Stephen Dec 22 '23 at 08:25
  • you can use TEXINPUTS=..//: pdflatex yourfile then it will find any file below the parent. – David Carlisle Dec 22 '23 at 10:02
  • Did I miss somebody suggesting using your home texmf directory? Typically, this might be ~/texmf/tex/latex/mypkg/mypkg.sty for example. No need for sudo or texhash and you don't have to remember TEXINPUTS every time you compile. You could also just link to a single copy, rather than duplicating, but that can get muddled more easily. – cfr Dec 23 '23 at 02:53

0 Answers0