Tx · LaTeX & TikZ

How to Add One Package to MiKTeX on Windows

Published By the 9to5Science editorial team

At a glance

  1. 1. Check the repository

    Search for the package in MiKTeX Console before copying files manually.

  2. 2. Install from MiKTeX

    Select the package and install it in the same user or administrator mode as your TeX editor.

  3. 3. Use a local root

    If the package is unavailable, place its files in a registered local TeX tree.

  4. 4. Refresh and test

    Refresh MiKTeX’s file name database, then compile a small document using the package.

If you need one LaTeX package in MiKTeX on Windows, you usually do not need to reinstall MiKTeX or copy files into its installation directory. Try MiKTeX’s package manager first. If the package is not available there, install its files in a separate local TeX tree that MiKTeX knows about.

The steps below apply to current MiKTeX versions. MiKTeX 2.9 uses older program names, but the same distinction applies: install a repository package with the package manager, or register a local directory for files you add yourself.

Install a package from MiKTeX

  1. Open MiKTeX Console from the Windows Start menu. If you have a shared, administrator-wide MiKTeX installation, launch the Console as an administrator when managing that installation. For an installation used only by your Windows account, use the ordinary user-mode Console.
  2. Open Packages and search for the package by its name. The package name may differ slightly from the command used in your document. For example, a LaTeX package you load with \usepackage{graphicx} may be listed under a package entry with a different name.
  3. Select the package and choose Install. If MiKTeX asks whether to install missing packages while compiling, you can allow that as an alternative, provided the prompt is enabled and MiKTeX can reach a repository.
  4. If the package does not appear, check that MiKTeX Console can access a package repository and that the package list is current. Menu labels can vary between MiKTeX versions.

Use the same installation mode in MiKTeX Console and your editor. A package installed only for your Windows user may not be visible to a TeX program running with a different account or in administrator mode.

Add files that are not in the repository

Manual installation makes sense for a package you received from its maintainer or a trusted source and that is not available through MiKTeX. A package may contain a .sty file, a class file, fonts, or several files. Keep its supplied directory structure where possible, and check its instructions for dependencies.

Create a local TeX root outside MiKTeX’s program folder. For example, you could create C:\localtexmf. Add that directory as a root in MiKTeX Console’s settings, then arrange the package files under the usual TeX directory structure. The exact settings page and wording can differ by version; look for the directories or roots configuration.

For a package called myexample with one file, the layout would be:

C:\localtexmf\
└── tex\
    └── latex\
        └── myexample\
            └── myexample.sty

If the downloaded archive already has folders such as tex/latex/myexample, copy those folders into the root rather than nesting them twice. For example, avoid accidentally creating C:\localtexmf\myexample\tex\latex\myexample\myexample.sty if the registered root is C:\localtexmf.

After adding files, use MiKTeX Console’s task to refresh the file name database (FNDB). MiKTeX uses that database to find files in registered roots; merely copying a file may not make it discoverable immediately. Some package types, particularly font-related files, can require additional setup or an update to generated files. Follow the package’s installation notes if provided.

Test the installation

Create a small file that loads the package and compile it with the same TeX engine and Windows account you normally use:

\documentclass{article}
\usepackage{myexample}

\begin{document}
Package test.
\end{document}

Replace myexample with the package’s actual name. If compilation succeeds, MiKTeX can find the package. If you get File 'myexample.sty' not found, check that the local root is registered, the .sty file is in the correct subdirectory, and the FNDB has been refreshed.

Common mistakes

  • Copying files into MiKTeX’s installation directory: This can require administrator access and may be undone or disrupted by updates. A registered local root is easier to maintain.
  • Using an unregistered folder: MiKTeX only searches its configured roots. A file on disk is not automatically available to LaTeX.
  • Installing in the wrong mode: User-mode and administrator-mode installations can have separate package sets and roots. Run the Console in the mode that matches the MiKTeX installation used by your editor.
  • Confusing a package with one .sty file: Some packages need several files or supporting fonts. Installing only the .sty file can lead to missing-file or missing-dependency errors.
  • Using an untrusted download: A TeX package can execute commands during compilation. Prefer MiKTeX’s repository or the package maintainer’s official source.

For a package listed in MiKTeX, use the package manager. For a package you must add yourself, use a registered local root and refresh the FNDB; do not modify MiKTeX’s program files by hand.

References

  1. MiKTeX documentation
  2. MiKTeX Console documentation

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.