[Tex/LaTex] Installing .sty package for Texstudio on Ubuntu 20.04


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.

Best Answer

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