This came up in a discussion of How to install additional LaTeX packages in Debian/Ubuntu. It seems to me that almost all users of Debian-derived OSes have two options when it comes to installing LaTeX packages: (1) using the native sources (including the recent backport in the case of Ubuntu 12.04 [or here]); or (2) installing TL from CTAN.

There seem to be several questions (e.g., here, here, here, here, here) , however, that ask how to install some package for Ubuntu users, and they all end up making the same two points: use option (1) or (2).

Thus, wouldn't it be useful to 'centralize' all these questions and make one big, general one that lays out these two options and their respective benefits (although not many people favor [1])? Then all these other questions could be closed with a link to the more general question.

For what it's worth, Best way to install packages for TeXLive in Ubuntu? might serve as the general question, and then we could close everything else. (Although I have no idea if we can/should close old questions with accepted answers....) However, it seems to me that a question with more unbiased answers would be better: i.e., instead of saying, 'don't do (1), do (2)', each answer lays out one option and all its benefits and drawbacks.

The "universal question" on the main site is: How do I install an individual package on a Linux system?

  • OK, so does upvoting in this case mean one is tacitly voting 'yes' as an answer to the question? (I can see that a simple 'yes' or 'no' as an answer is hardly worth submitting, but I suppose an upvote might also indicate that the voter thinks this is a question that deserves further discussion here on meta.)
    – jon
    Aug 8, 2012 at 3:42
  • As this is now actioned, perhaps 'accept' the 'answer'.
    – Joseph Wright Mod
    Sep 18, 2012 at 14:41
  • @JosephWright -- Ahh, right. I forgot it was up to me....
    – jon
    Sep 18, 2012 at 14:43

2 Answers 2


This does feel a big thing for one person to take on and get right straight away so let's draft it here. CW for easy editing.


I need to install a new TeX/LaTeX/ConTeXt package on my computer. I'm running Ubuntu/Fedora/Slackware Linux. What are the possible ways to do this?


Method 1:

Find and install the package through your package manager.

This is for if you are using the version of TeX that came with your distribution and you don't mind particularly which version of the package you install.

Linux distributions tend to include TeX as a collection of packages, but it isn't usually on as fine a level as one TeX package equals one Linux package. You therefore need to find the right distribution package containing the TeX package that you want and install it. Different package managers have different methods of searching, if all else fails there is often a website where you can search for a specific file:

Method 2

Install the latest TeX Live

This is for if the package is in TeX Live and you want to or are using 'vanilla' TeXLive.

If you haven't yet installed TeX Live, follow the instructions at How to install "vanilla" TeXLive on Debian or Ubuntu?.

How you install a package via TeX Live depends on whether you installed TeX Live as a single user or you installed it system-wide. If the first, try:

tlmgr install <package>

If the second, you will have a small problem in that tlmgr might not be in the path that sudo automatically searches. So you need to locate it first and use sudo to call it with the full path. If your shell has the which builtin, you can find tlmgr using the command which tlmgr. Thus:

which tlmgr
sudo /path/to/tlmgr install <package>

If your shell allows you to use the output of a command as a sort of variable, you can use the following command to condense the above (where we exploit the fact that which returns a single instance of the command regardless of how many times it appears on the path):

sudo $(which tlmgr) install <package>

(You can test your shell with the less risky echo $(which tlmgr): this should produce the same as which tlmgr.)

Method 3

Install manually

In this situation, you have two options: to install system-wide (all users on your system) or to install just for you. System-wide means that any user on your system will be able to use it, just for you means just that: it will only be installed for your account. The difference between the two is the base location:

  • System-wide: type kpsewhich -var-value TEXMFLOCAL in the Terminal to find the right directory
  • Just for you: type kpsewhich -var-value TEXMFHOME in the Terminal to find the right directory

What happens now depends a bit on the package. If it is distributed in TDS then you are in luck. Go to the directory reported by kpsewhich, and into the tex subdirectory (or create it if it does not exist). Then extract the TDS file (remember to use sudo if globally, and check that your umask is set to 022). Note check the TDS file first to ensure that it will extract into the right place: you may need to move up or down a directory to get it to match.

If it is not distributed in TDS, then there might be instructions - in which case follow them - but the general pattern is pretty similar. If it is a LaTeX package, create a directory in <base dir>/tex/latex/<package name> for it and extract the files (.sty plus perhaps .cls, etc.) there. Documentation files go in <base dir>/doc/latex/<package name>.

If you installed it globally, you will now need to run mktexlsr (or equivalently texhash) via sudo. If mktexlsr is not in the path that sudo searches, you will need to locate it. You can do:

which mktexlsr
sudo /path/to/mktexlsr

Or if your shell allows it:

sudo $(which mktexlsr)

This isn't necessary for local installations.

Note on sudo

When you add TeX Live to your path, it will not normally be added to the path for the root user, so will not be visible using sudo. The methods above use which to find tlmgr , etc., from the 'normal user' path and pass the correct instruction to sudo. This works with the bash and zsh shells: if you use another shell you may need to provide the full path to tlmgr instead.

  • If you do a 'vanilla' install, tlmgr and mktexslr are not on root's path. How do we want to cover that?
    – Joseph Wright Mod
    Aug 30, 2012 at 6:26
  • @JosephWright Good point. The user will have to do which tlmgr to find its location and then run sudo <wherever it was>. Actually, with zsh (and probably some others) you can do sudo $(which tlmgr) because the $(which tlmgr) will get expanded first by the shell before sudo is called. Aug 30, 2012 at 8:01
  • Also seems to work with bash: on my Ubuntu test system sudo $(which tlmgr) update --self --all works fine. Probably we should go with that with a note to explain why.
    – Joseph Wright Mod
    Aug 30, 2012 at 8:45
  • This looks like a pretty good question-and-answer of what I was suggesting. I'd certainly upvote the question and answer (which should be, I think, a 'community wiki').
    – jon
    Aug 30, 2012 at 18:48
  • Should ‘Method 0’ be ‘put it in the same directory as the source file’? That's not really ‘installing’ it, of course, but it may be the most straightforward route to the desired effect (separately, if the package in question is a beta version from the author, or a custom version, or..., then a ‘proper’ install may be disruptive). Alternatively, ‘put the files in a subdirectory and write TEXINPUTS=subdir:’ might be enough (that blush is probably what I'd do myself). I – offering a beta in an answer here – am on the hunt for just such a Q&A to point to. May 24, 2016 at 10:36
  • Hmm: I've just noticed that this Q&A is now four years old! May 24, 2016 at 10:37
  • @NormanGray This was transferred to the main site (and improved). You can add your Method 0 to it there if you like: tex.stackexchange.com/q/73016/86 May 24, 2016 at 16:28
  • @LoopSpace Another commented pointed me towards an existing collection of questions, and I added this question to that list. On reflection, I think my ‘method 0’ isn't quite comparable with the others, since they're concerned specifically with packages as opposed to random .sty files. May 26, 2016 at 12:42
  • @NormanGray I tend to the inclusive end of the spectrum on answers. I can imagine someone effectively wanting your answer and finding that question, so I would add it. If you don't think it works as part of the main answer, you should feel free to add it as a separate answer. May 26, 2016 at 17:32
  • @LoopSpace Done: I added a method 4 May 28, 2016 at 11:40

I am wondering why there is no answer to this question up to now when, at the time of this writing, 20 people already upvoted it. So I understand jon's concern. In fact, I have recently answered a question about installing TeXLive on Ubuntu 12.04. The OP even awarded a bounty for it. The question was TeX Live — problem with install [Ubuntu, bash]; new packages. I realized now from reading the links provided in the question that the questions are very much alike and are actually duplicates of each other if not for asking about specific packages. There seems to be two general considerations when faced with the questions: 1) Vote to close the question for possible duplication, and 2) answer the question or provide links in comments to previous posts in order to encourage the user to have greater future participation in TeX.SX (since it looks like most of the posts were done at the time when the OP is relatively new to TeX.SX). Maybe one way to go about it nicely is to comment that some posts have already been written which closely resemble the problem and post an encouragement to post more questions in the future and post a link to some guidelines when posting a question.

  • 1
    There's no answer because the question is generally saying: "I think it would be good to ..." And on meta we tend to simply agree by up-voting. Generally, once there're "enough" upvotes, either the OP or some Mod or similar simply do it.
    – yo'
    Aug 29, 2012 at 8:41
  • 3
    Indeed, it's mainly a question of someone doing the work. I suspect what we need is a question to be asked then self-answered by someone, so that the question is sufficiently clear and general that we can treat it as the 'master' question.
    – Joseph Wright Mod
    Aug 29, 2012 at 8:44
  • @tohecz so that answers jon's question in his comment above, too. My point is that some people new to meta and to tex.sx will be somewhat anxious to answer their own questions until they have a written reply (and not just upvotes). I certainly feel that way. :)
    – hpesoj626
    Aug 29, 2012 at 10:38
  • @hpesoj626 sorry, we're not perfect ;) but as you can see, it is enough to ask and it does not hurt :)
    – yo'
    Aug 29, 2012 at 16:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .