1

I created a new package as a .sty file. I want to be able to use it in all of my documents.

I followed the instructions on the MacTeX website. I located my Library folder in Macintosh HD using Command + Up. It had a TeX folder, but no texmf folder, so I created one. In fact, I created the following subdirectory (at least that's what I think it's called) :

~/Library/texmf/tex/latex.

I added my file, mystyle.sty, to this folder. Then I attempted to compile a minimal document using the command \usepackage{mystyle}. I got the error message File 'mystyle.sty' not found. What should I do?

  • On the folder latex, create a subfolder Mystyle, and in it add the file mystyle.sty. I'm not sure if you can directly add mystyle.sty in the root of the latexfolder. Does this advice help? – quark67 May 03 '19 at 21:17
  • @quark67 That did not fix the problem I get the same error message. –  May 03 '19 at 21:19
  • @quark67 Now mystyle.sty is in the folder ~/Library/texmf/tex/latex/Mystyle –  May 03 '19 at 21:20
  • When I have manually installed a package which was not in TeX live, but available in CTAN, I always do as I previously say, and never had error. Have you tried with your .sty file in the same folder as your .tex file? Is the compilation correct with .sty here? – quark67 May 03 '19 at 21:31
  • @quark67 Yes it works fine then. But I’d prefer not to have to organize things that way if possible. –  May 03 '19 at 21:34
  • I read answers of this question: Where do I place my own .sty or .cls files, to make them available to all my .tex files?, specifically for MacTeX. I don't see your error. Perhaps you could add the tag [mactex] in your question for more visibility. – quark67 May 03 '19 at 21:50
  • @KJO From the MacTeX website linked above: "It is not necessary to run texhash when adding files to this local tree." –  May 03 '19 at 22:13
  • @simplejack agreed texhash not always needed if it is in the correct TDS relative position but should not cause harm as it is done regularily –  May 03 '19 at 22:15
  • @KJO No, it's better not to run texhash on the local folder. – Alan Munn May 03 '19 at 22:16
  • I typed texhash in Terminal and clicked Enter but it didn't fix the problem. –  May 03 '19 at 22:17
  • 1
    Just to be clear, you're sure you created the texmf folder in ~/Library, i.e., in the library folder of your home directory, and not /Library? In the Terminal, what does the command ls ~/Library/texmf/tex/latex return? – Alan Munn May 03 '19 at 22:17
  • @AlanMunn ok noted but texhash should only work where its supposed to traverse should it not –  May 03 '19 at 22:18
  • I think so. It is in the same folder as System and Users. It is in the second highest level after the one with Macintosh HD, Network, etc. –  May 03 '19 at 22:18
  • 2
    No, that's incorrect. That's the system library. You need to make the folder in the library that is in your home user folder. – Alan Munn May 03 '19 at 22:19
  • @AlanMunn I moved it and it works now. Thanks a lot, sorry for the confusion. I don't know what I'm doing. –  May 03 '19 at 22:22
  • Sounds like you are using /Library, the Library folder at the root of your HD. You should be using ~/Library, the Library folder in your HOME folder. That Library folder is normally invisible. To open it in Finder click on th Go menu and hold down the Option key to see a menu item to open that folder. You can make it permanently visible if you HOME folder but opening that folder, typing Cmd-J, an checking the box about it. – Herb Schulz May 03 '19 at 22:27

1 Answers1

0

The local texmf folder has to be created in your home Library folder, not the system library folder. You can navigate to that folder from the Finder by using the Go Menu: (Command-Shift-G) Goto Folder.

enter image description here

In the dialogue box type ~/Library (the ~/ is important).

Now you can create the texmf folder. For a LaTeX package, it minimally needs to have a folder tex, containing a folder latex, and optionally a folder for your style file itself (although this is strictly speaking not necessary).

Alan Munn
  • 218,180