98

According to my ubuntu 11.04 my texlive is the latest version. But when I tried to \usepackage{algorithm} it says file algorithm.sty is not found. I read the algorithm.pdf manual and tried latex algorithms.ins in terminal and again it says file not found. So what is the problem here? I installed texlive using sudo apt-get install texlive but it seems to be missing some packages that were suppose to be included. How do I fix this?

2
  • TeX will only search the local directory, or the TEXMF tree. Where did you "compile" algorithm.ins?
    – Werner
    Commented Sep 16, 2011 at 2:10
  • @Werner: Silly me I thought latex would fetch algorithm.ins from server or something like apt-get. I have just successfully run latex algorithms.ins. Do you know where I should put the sty files?
    – Mark
    Commented Sep 16, 2011 at 2:15

12 Answers 12

128

sudo apt-get install texlive does not install all packages from CTAN. sudo apt-get install texlive-full does that (well, it installs everything that was on CTAN when the package was created).

If you do not want to install everything, you can just install texlive-science which contains the various algorithm-related packages.

On Arch the equivalent meta package is texlive-most.

4
  • How come it says tlmgr not found?
    – Mark
    Commented Sep 16, 2011 at 15:08
  • 2
    @Mark: That's the whole point: The Ubuntu/Debian packages do not include tlmgr. Only a direct install of Tex Live does that.
    – Caramdir
    Commented Sep 16, 2011 at 17:30
  • @Caramdir, Fedora/Red Hat has also split up texlive into a lot of packages, and (consistent with the philosophy of one tools for each job) they are handled as normal packages, i.e., no lexlive manager (tlmgr ;-) wanted.
    – vonbrand
    Commented Jan 13, 2016 at 17:54
  • 7
    If you wanted to figure out which package provides that file, you could use the command apt-file find algorithm.sty. (Teach a man to fish...) Commented Apr 14, 2017 at 15:37
29

As mentioned before, texlive doesn't install the entire TeX Live distribution. To install everything, you should use texlive-full, but it contains many packages that you will not even dream of using in the real life.

If you are using Debian/Ubuntu and want to use algorithm + algorithmic, then I would suggest that you simply install texlive-science and go on with life.

If on the other hand, you are feeling adventurous (not really), you may want to check the new version that I have been baking for some time on github, but have still not uploaded to CTAN.

The new version features a slightly easier, streamlined installation procedure, with you having to worry about just one file, algorithms.dtx.

As the original question was about Debian/Ubuntu, I would like to point out a very valuable resource that many may not know, which is the Debian/Ubuntu-specific information on TeX Live. There you will see directives on how to maintain your local packages from stepping onto the distributed versions of those packages, to ease the maintainance task, detailed in Chapter 4.

19

For those who use tlmgr and were sent here because of modern search engine's tolerance for typos @drozzy's answer got me on the right path:

tlmgr install algorithms

did it. Trying this for algorithm or algorithmic individually didn't work.

1
  • This worked for me on MacOS Ventura 13.1 (with sudo)
    – Sohail Si
    Commented Jun 5, 2023 at 20:37
5

Compiling algorithms.ins in the local working folder (wherever you are currently working in) will produce algorithm.sty and algorithmic.sty that you can leave it there. This is the first place that TeX will search for style and class files. However, if you're interested in using these styles for other projects as well, then you have to put it in the TEXMF tree. I am not familiar with Ubuntu's tree structure, but I'm guessing it will be located in

/usr/local/texlive/2011/tex/latex/

In the above location, make a folder algorithms and place algorithm.sty and algorithmic.sty in there, and run texhash.

1
  • Better put it into the local TEXMF tree (I believe ~/.texmf) instead of the system-wide one. That way you don't interfere with the package manager. (Except of course if you want it to be available for several users — then you need to use a system-wide directory.)
    – Caramdir
    Commented Sep 16, 2011 at 3:00
3

I follow these steps (I use vanilla TexLive from CTAN) --

Step-1: During compilation, you suppose to get this type of error message if a package/style file is missing -

! LaTeX Error: File `sublabel.sty' not found.

Type X to quit or to proceed, or enter new name. (Default extension: sty)

Enter file name:_

Step-2: If X.sty is missing, search on google for it, like "X.sty + CTAN", you also supposed to get a link like below --

www.ctan.org/tex-archive/macros/latex/contrib/preprint/‎

Step-3: In CTAN, generally many stlye(.sty) files are packaged under some other folders. In this case, sublabel.sty is packaged under preprint (Note the root folder www.ctan.org/tex-archive/macros/latex/contrib/Y). So, X.sty is packaged under Y. Or to make sure, you can go to the link to check if X is really in Y.

Step-4: Now install Y, use tlmgr (generally shipped with 'TexLive') --

sudo ./tlmgr install Y

Everything related to Y (in this case X) will be installed.

2

I faced one problem my algorithms.sty package was not being recognized even though it was installed. I went to folder it was installed and saw that folder name is algorithms but file name is algorithm.sty hence I changed that to algorithms.sty and now its working fine. Hope it helps some of you.

2
  • 2
    But you probably used \usepackage{algorithms} rather than \usepackage{algorithm}.
    – Werner
    Commented Oct 3, 2012 at 5:22
  • 4
    Admittedly it is confusing: There is the bundle algorithms that consists of the packages algorithm and algorithmic. The directory name is correct, it is named according to the bundle name. Also the file name was correct before your change. The package is loaded with \usepackage{algorithm}. Also the package file itself says: \ProvidesPackage{algorithm}. Using a different file name will trigger a LaTeX warning: You have requested package algorithms, but the package provides algorithm. Commented Oct 3, 2012 at 6:00
2

This is because there is no algorithms package, only algorithmic and algorithm packages.

So you should do this instead:

% "algorithms" bundle
\usepackage{algorithmic}
\usepackage{algorithm}

It is really confusing because the official doc calls "algorithms" a bundle: http://mirror.its.dal.ca/ctan/macros/latex/contrib/algorithms/algorithms.pdf

but then goes on to say:

This package provides two environments, algorithmic and algorithm

0

Here's the command for OpenSUSE:

 zypper in texlive-algorithms
0

The package algorithms install two packages: algorithm and algorithmic. Each of these two packages will have style files namely: algorithm.sty and algorithmic.sty. These files are located somewhere in your installation path, e.g.,: C:....\miktex\tex\latex\algorithms.
Import these packages using the following two statements:

\usepackage{algorithmic}
\usepackage{algorithm}

Then at the beginning of your document try very simple statements such as

\begin{algorithmic}
\STATE $S \leftarrow 0$
\end{algorithmic}

Then compile your TEX file and see, does it produce the algorithmic statements or not.

0

If you need style file algpseudocode.sty then in Package Manager of MiKTeX search the file algpseudocode.sty by writing its name in the File name text field. The search result will show that the file is in the package algorithmicx. Then install the package algorithmicx. `

0

On Cygwin algpseudocode.sty is found in the package texlive-collection-mathscience.

0

As mentioned in this answer, on Ubuntu systems, you can just use the Ubuntu Packages Search for the file algorithm.sty. For bionic and focal it indicates that texlive-science should be installed, which is smaller than texlive-full.

You must log in to answer this question.

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