How to install a .sty package that is missing when a tex file is being built by Texstudio for Ubuntu 20.04? Any method would work for me, but preferably a method via terminal or preamble of the tex file would be the most useful.

  • 1
    You don't install packages in TeXStudio!. TexStudo is an editor. You need to install the package into your latex installation. For that we need to know exactly what LaTeX you use? Since you are on Ubuntu, you either installed via the Ubuntu package manager (in that case use apt-file to figure out which Ubuntu package provide this latex package). If you installed LaTeX by hand (from tug.org/texlive) then you should already have all latex packages but in case you installed a minimal installation you can use tlmgr to install packages. – daleif Jan 22 at 11:38
  • Thanks for the reminder @daleif - for some reason I forgot the separate latex installation. I installed texlive-latex-recommended but still get the error saying that mathcomp.sty package is missing. – tachyon Jan 22 at 15:06
  • I just had a look on that package, that seems to be units, use the siunitx package insteads, that is the standard now. Much has changed since 2001 when mathcomp was last updated. – daleif Jan 22 at 15:17
  • Besides according to my ubuntu 18.04 (via apt-file, remember to run sudo apt-file update) mathcomp.sty is in texlive-science. Note that this splitting into many Ubuntu packages is why I use upsteam TeXLive and can thus install individual packages using tlmgr – daleif Jan 22 at 15:19
  • Thanks @daleif , it solved the problem! You can formulate it as an answer for this question :) – tachyon Jan 22 at 15:24

First of mathcomp seems to just provide some symbols to write units. Nowadays the latex standard is to use the siunitx package instead.

Regarding mathcomp and texlive-latex-recommended from Ubuntu. Ubuntu splits TeXLive into several Ubuntu packages (not to be confused with LaTeX packages, they often contain many latex packages). Given that mathcomp is not a widely used package it is unlikely that it is listed in texlive-latex-recommended, might be easier to just install it all texlive-all I think it is called(?)

Personally I don't use TeXLive from Ubuntu as I'd like to get the latest updates so I use the upstream one (see http://tug.org/texlive).

If you use Ubuntu and the TeXLive that Ubuntu provides the way you figure out which Ubuntu package a given latex package belongs to is to make sure you have apt-file installed

sudo apt install apt-file
sudo apt-file update

Run the latter command from time to time.

Then search a latex package via for example

apt-file search mathcomp.sty

and here it tells me

texlive-science: /usr/share/texlive/texmf-dist/tex/latex/mathcomp/mathcomp.sty

so I would need to install texlive-science


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.