84

I've searched online, but I have not found any clear instructions how to permanently add .sty files to my TeXShop installation. I'm using a Mac with OSX (TeXShop is a mac only program).

What is the best way of doing this? The one comprehensive set of instructions I found here.

I've got as far as extracting the files (running LaTeX on the .ins and . dtx files) but after that I don't know what to do. I also don't understand how to update the index of my distribution, and whether there are particular OSX specifics (the instructions are for Windows).

Alan Munn
  • 218,180
celenius
  • 5,274

6 Answers6

68

The first question you should ask is whether the package you are trying to install is already installed on your system. If you are using MacTeX as your distribution (which you probably are) then most packages are already available. Within TeXShop you can choose the "Show Help for Package" item from the Help menu and enter your package name. (Or make a simple document that loads the package to see if it doesn't exist.)

Installing packages or classes

If the package doesn't exist, then this answer:

covers everything you need to know.

On a Mac, local additions go into the Library/texmf folder of your Home folder (~/Library/texmf). Unfortunately on OS 10.7 and above, the user Library folder is typically hidden from view. It is, however, easy to access it through the Finder's Go menu: hold down the Option key while choosing the Go menu, and the local Library folder will appear in the list. Alternatively if you type Command-Shift-G you can enter the folder path directly (~/Library/texmf)

You never need to update the file database for local additions to this folder.

If the texmf folder doesn't exist, you will need to create it yourself along with the subfolders necessary for TeX to find things properly (see the linked question for the correct hierarchy). For a one-click version of this you can use this utility:

Installing fonts for pdfLaTeX

Fonts which are to be used with pdfLaTeX should never be installed in this folder. See the following question for details about how to install fonts properly.

Installing fonts for XeLaTeX or LuaLaTeX

These fonts should not go in this folder either, but should be installed as system fonts in the same place that any font on your machine would go. On a Mac this is `/Library/Fonts`.
anol
  • 539
Alan Munn
  • 218,180
  • Perhaps you should mention something about the TDS... – Seamus Feb 04 '11 at 15:09
  • 2
    @Seamus that's what the linked answer is. – Alan Munn Feb 04 '11 at 15:46
  • 3
    Alternatively to permanently unhide your ~/Library directory on 10.7 (Lion), simply run chflags nohidden ~/Library/ in Terminal. :-) – user2473 Jan 26 '12 at 00:26
  • For Mac OS 10.7, I recommend XtraFinder, which works on top of the Finder, and which has the option View -> Show Hidden Items – PatrickT Feb 15 '14 at 07:04
  • 1
    Amazing, ur app really works and helps!!!! – Charles Yan Jun 09 '16 at 15:13
  • This is really rather confusing since what you describe creating is not a local tree, but a personal tree i.e. TEXMFHOME and not TEXMFLOCAL. Could you modify it to avoid this confusion? Surely new users have enough pitfalls already, without our adding extras ;). – cfr Jan 12 '18 at 00:23
  • @cfr I'm actually loath to change this, since I think that the local vs home distinction is largely lost to most users these days, since we tend to use single user machines for which TEXMFLOCAL is for all intents and purposes irrelevant. And we can find the term 'local texmf tree' used all over to mean what is technically TEXMFHOME. – Alan Munn Jan 12 '18 at 04:21
  • @AlanMunn It matters hugely when installing fonts! If you install those into TEXMFHOME, you get no end of headaches: there really is no good way to do it at all. I actually recommend avoiding the use of a font package if that's your only option - it just isn't worth the pain. Installing into TEXMFLOCAL, on the other hand, is (relatively) pain-free and practically paradise in comparison. My Q&A on this strongly depends on the LOCAL/HOME distinction. It matters massively. (And some people do still use traditional fonts - real people and not just me!) – cfr Jan 12 '18 at 04:25
  • There are other important differences, of course. For example, you need to update the file database if you install into LOCAL, but not HOME. Etc. But that just causes stuff not to work properly. It doesn't screw things up months from now when you've completely forgotten all about it. – cfr Jan 12 '18 at 04:27
  • You should also mention that your instructions ought NOT be followed if the package supports or includes fonts other than support for FontBook-installed fonts with Xe/LuaTeX. – cfr Jan 12 '18 at 04:29
  • @cfr Yes, fonts is absolutely the one place where it most definitely makes a difference, and I agree. So making the distinction explicit in those contexts sense. – Alan Munn Jan 12 '18 at 04:30
  • @cfr I've added some comments about fonts. Is that better? – Alan Munn Jan 12 '18 at 04:39
  • Yes, that is better. But I still think it is unnecessarily confusing, since the truth is that font packages should be installed in the local tree, which is not the one you're calling 'local'. 'These should be installed in the local tree rather than this one' would be the obvious thing to say, except that 'this one' is the one you've described as 'local'. – cfr Jan 12 '18 at 17:22
13

To add cls package (like moderncv) in my OS distribution with texlive 2015, I just unzip package under /usr/local/texlive/2015basic/texmf-dist/tex/latex. Don't forget to run sudo texhash!

Hope this help.

7

If you’re using BasicTeX (86 MB) instead of full-blown MacTeX (2.3 GB), e.g. to save valuable disk space on a MacBook Air, you’ll only find the most common packages and classes in your installation. To add more, the simplest option is the TeX Live Utility which you should find in your application folder. It also updates packages to the most recent version found on CTAN.

My /usr/local/texlive folder structure currently weighs in at well below 400 MB.

Crissov
  • 1,866
6

If you're using mactex, just follow the instruction you have provided in the description, move the relevant file into the directory, e.g., move *.sty file to /usr/local/texlive/texmf-local/tex/latex/local, then run sudo texhash

Hanchen
  • 61
  • This seems to be covered, to some extent, by the other short answers. – Werner Oct 23 '18 at 22:31
  • Unless you're installing a package for use by multiple users on the same machine, it's much simpler to put things into ~/Library/texmf, since you don't need to run texhash and can do everything from the Finder. – Alan Munn Oct 24 '18 at 02:15
5

How to put .sty and .cls Files where TexShop will find them:

Personalised sty files are stored in ~/Library/texmf/tex/latex.

The folder ~Library is a hidden folder. In Finder, click on your home folder in the Finder directory tree on the left hand panel of the Finder.

Next, the hidden folders then need to be made visible. This is done from a terminal. The terminal should open by default in your home folder.

Type into the command line:

defaults write com.apple.finder AppleShowAllFiles YES

followed by

killall Finder

The hidden files in you home folder should now be visible.

Choose the Library folder, then texmf, then tex, then latex. The sty files, or folders contain sty and cls files, can be placed into this folder.

Next, we need to make the hidden files invisible again. To do this, type into the terminal:

defaults write com.apple.finder AppleShowAllFiles NO

Then type

killall Finder

The hidden folders should now no longer be visible.

Torbjørn T.
  • 206,688
  • Welcome, using a terminal to make folders visible, move files, make folders unvisible again? Wow, OS X is complicated. Can't you just mv the files in your terminal? A decent bash will show you everything with the very simple ls -a. – Johannes_B Jun 04 '16 at 12:09
  • 1
    This really is not necessary. You can access hidden folders from the Go menu (see my answer for how). Also, once you've unhidden the folders, there's really no need to hide them again. Furthermore, since unhiding the Library is a generally useful thing, rather than unhiding all hidden files, it's better to selectively unhide the Library folder only by using chflags nohidden ~/Library/. – Alan Munn Jun 04 '16 at 20:02
  • @Johannes_B: that can be done on the Mac too. Under Yosemite and later you can also make it permanently visible in Finder by simply opening the HOME folder, typing Cmd-J and choosing to make it visible. From then it's visible in the HOME folder. – Herb Schulz Jun 08 '16 at 00:47
  • @AlanMunn So does Mac OS X no longer fade everything if you show so-called invisible files? That's what it started doing - bloody nuisance and certainly the only reason I started hiding them again. – cfr Jan 12 '18 at 00:26
  • @cfr I really have no idea. I never use the Finder for system files anyway, so I've never encountered the problem. – Alan Munn Jan 12 '18 at 04:17
  • @AlanMunn I don't even have a file manager installed. I used to, but it only ever got opened automatically when I didn't want it - I never deliberately used it. So it seemed pointless. – cfr Jan 12 '18 at 04:19
0

This worked for me on Catalina without digging into ~/Library/texmf

sudo chown -R ${USER}:staff /usr/local/texlive
tlmgr install wrapfig
  • Welcome to TeX.se. Had you installed BasicTeX? wrapfig should have been installed with a full MacTeX installation, so you shouldn't have needed to install it manually. – Alan Munn Apr 14 '20 at 19:45
  • 1
    Also instead of changing the owner of /usr/local/texlive you should have just run tlmgr using sudo. – Alan Munn Apr 14 '20 at 21:00