[Tex/LaTex] How to manually install a package on MiKTeX (Windows)

installingmiktexpackageswindows

I'm new to LaTeX, investigating using it for some work projects. I'm using MiKTeX on Windows. My employer's locked-down network blocks the application's automatic installation function. I can take my laptop home and successfully install from there, but if I need a package in the middle of the day I'm stuck.

I am able to access the CTAN website and download the package files (.dtx or .ins?), but I don't know what do do with them. How can I do a manual package installation?

Best Answer

Firstly, check README files, available documentation of the package, perhaps the beginning of the .dtx file to get installation information.

Installing a package available as dtx/ins bundle:

  • Download the content of the package directory. dtx is the extension of a documented source file, ins is the extension of an installation file. Put this in a temporary directory.

  • If there's nothing differently written in a README file run LaTeX (or TeX) on the .ins file. This is best done using the command prompt (latex packagename.ins), but you may use your TeX editor in LaTeX/DVI-LaTeX mode or what it is called there. This would usually produce one or more files ending with .sty, perhaps some additional files. As you now have cls or sty files or the like, the remaining steps are the same like in the next alternative way:

Installing sty or cls files:

  • Create a new directory with the package name in your local texmf directory structure, see also Create a local texmf tree in MiKTeX. Why not to choose the main MiKTeX texmf tree see in Purpose of local texmf trees.

  • Copy the package files (*.sty, *.cls etc.) into this directory.

  • Make the new package known to MiKTeX: refresh the MiKTeX filename database. To do this, click "Start/ Programs/ MiKTeX 2.x/ Maintenance/ Settings" (or similar) to get to the MiKTeX options, click the button "Refresh FNDB". The installation is complete.

  • If you did not download the documentation already, you could get it by running pdfLaTeX or LaTeX on the .dtx file. Compile twice to get correct references.

Obtaining and installing packaged universal archives:

Perhaps you could get a file with the extension .tds.zip. Such files are archives fitting to your TeX directory structure. Open it, check the content structure. You could extract it to the right place. Also here, as after any installation, refresh the MiKTeX filename database.

Installing a font package

Installing a font package, especially for Type1 fonts, requires additonal steps. See Manual font installation.

Links with further information:

A different and very effective way, using a local repository:

(works only for all in the MiKTeX package repository available packages)

  • Use the MiKTeX net installer to download the complete MiKTeX repository to a USB drive.

  • On a MiKTeX system, choose this directory as the local package repository in the package manager.

  • Use this local repository for installation and updates.

  • You may update that local repository later using the net installer: it loads the database from the server, compares and downloads new or updated packages.