How to Use LaTeX Packages with Examples

How to Use LaTeX Packages with Examples

Want to learn how to install and use LaTeX packages? This guide will show you how to do each of these tasks quickly.

What are LaTeX Packages?

The popular document preparation software LaTeX includes numerous packages. These packages add new options or functions to the basic TeX distribution software. 

There are many different types of LaTeX packages available. They can generally be categorized as either one of the following:

  • Packages that enable users to alter the structure of their document, such as setspace.
  • Packages that enable users to add new types of content to their document, such as amsmath for advanced math extensions.

How Do Packages Work in LaTeX?

Packages can be viewed as an extension of the mechanisms present in LaTeX. LaTeX itself is composed of TeX macros, as are the packages it uses. LaTeX defines the various commands and interfaces that enable TeX code in each package to be executed.

List of Commonly Used LaTeX Packages

Some of the most popular LaTeX packages include:

  1. amsmath: Introduces advanced math extensions to LaTex
  2. array: Extends the range of functions and customization options for tables in the document.
  3. biblax: Offers advanced bibliography functionality. This package is popular for creating theses.
  4. booktabs: Offers extra commands and optimisation options for tables.
  5. caption: Adds more appearance and placement customization options for captions in tables, figures, etc in the document.
  6. cancel: Adds commands to strike out mathematical expressions.
  7. changepage: Enables users to easily change page margins.
  8. cleveref: Adds more cross-referencing features to LaTeX. It is useful for formatting references automatically according to their type.
  9. esint: Adds more integral symbols, clockwise integrals, and integrals for squares.
  10. fancyhdr: Allows users to change the header and footer of each page in the document.
  11. geometry: Offers easier management of margins and page size in the document. 
  12. glossaries: Enables the creation of glossaries and a list of acronyms in the document.
  13. hyperref: Provides LaTeX with the capabilities to manage links within the document.
  14. listings: Enables users to insert programming code in their document.
  15. longtable: Allows users to create tables that extend to the next page.
  16. mathtools: This package supplements ansmath and offers additional functionality.
  17. natbib: Offers new citation styles and options. Useful for journalistic documents.
  18. rotating: Allows users to rotate objects such as tables in the document.
  19. theorem: Enables you to alter the style of newly defined theorems.
  20. ulem: Allows users to underline text using a straight or a wavy line.

Where Can I Download LaTeX Packages?

Users can download LaTeX packages from the MiKTeX website. There are currently over 4500 packages within the MiKTeX package repository linked above. New LaTeX packages are added frequently, and add to software’s ever expanding  functionality and customizations options.

How to Install LaTeX Packages Automatically

Users with MiKTeX can use the package manager to choose the packages they would like to install individually. MikTeX also automatically prompts users to install missing packages when a file requiring an additional package is installed.

How to Install LaTeX Packages Manually

It is possible for users to install LaTeX packages manually using the following steps:

Step 1: Download and Extract the Package Files

The first step is to download your package file. Users can download their LaTeX package files from here. Once the download is complete, right-click on the folder and select “Extract All”. Then choose the destination for the extracted files. 

Step 2: Install the “.ins” File

Navigate to the folder where the extracted files are stored and locate the “.ins” file. Then type in “cmd” in your window’s search bar to open Command Prompt. Next, type “latex {package name}.ins” and hit the Enter key.

The LaTeX file will then be installed. Hit the Enter key to return to the starting command.

Step 3: Locate the .sty File

Return to the folder where the files were originally extracted. There should now be a .sty file for the package. 

Step 4: Create a New Folder

Users should then create a separate folder called “packages” to add their package to LaTeX. Within this folder, users should make another folder and name it “tex”. Within the “tex” folder, users should create a folder named “latex”. 

This folder structure is used because MiKTeX recognizes packages in this manner.

Step 5: Add Extracted Files to “latex” Folder

Navigate to the folder where the files were extracted. Copy this entire folder and paste it in the “latex” folder. 

Step 6: Open MiKTeX Settings

Next, navigate to the MiKTeX Settings app in the Windows Start Menu search. Click the “Roots” tab in the window that opens. Then click the “Add” button and navigate to the “packages” folder created earlier. Select “OK”. 

The “packages” folder should now be visible in the window. Click the “Apply” button, and a MikTeX Maintenance window should pop up and automatically import the files. Once this is complete, select the “OK” button.

How to Use LaTeX Packages?

You can use LaTeX packages by inserting the syntax \usepackage{package name}. For example, the code for using the amsmath package would resemble:





  f(x) = x^3



Final Thoughts

As you can see, installing and using packages in LaTeX is a relatively straightforward process. These packages add to LaTeX’s already massive range of functionality and features, so consider trying out different ones for your next document.

Frequently Asked Questions

Some frequently asked questions related to LaTeX packages are shown below.

Q1. How Many LaTeX Packages Are There?

There are over 4500 LaTeX packages available at the MikTeX website. These packages offer additional functionality or customization options for your LaTeX document.

Q2. Where Do I Put Packages in LaTeX?

You should create a custom folder for your LaTeX packages. The above example includes a folder called “packages” that contains a folder called “text” that contains a folder called “latex”. These folders can be placed in any drive as long as you can navigate to them when you run MikTeX Settings.

Q3. Why aren’t Packages Pre-Initialised in LaTeX?

Packages do not come pre-initialized in LaTeX because there are thousands of them. Including all these packages with LaTeX by default would increase the software size greatly. In addition to this, many packages clash with one another. For this reason, users must add packages according to their specific needs. 

Q4. How Can I Disable Automatic Package Installation?

As mentioned earlier, MiKTeX has the ability to install missing packages automatically. However, some users may wish to disable this feature and install each package manually. This feature can be disabled by navigating to the “Settings” page in MiKTeX, clicking the “General” tab, and clicking the “Never install missing packages on the fly” option.

Photo of author
Joannah W.
Joannah has been a science publisher with close to 20 years of experience. She wants to help students and researchers stay ahead of the trends and developments in the science community by making science more accessible to everyone.

Leave a Comment