1. Introduction

LaTeX is a document preparation system mostly used for academic purposes. One of the essential features of LaTeX is the possibility of using different packages.

Packages, in turn, are collections of additional commands and features that can be easily imported into a LaTeX document. In this way, they add functionalities to the LaTeX documents without requiring us to write their code from scratch.

In this article, we’ll explore how to use packages in LaTeX and load them into our documents. Furthermore, we provide a practical example of using a package.

2. Installing Packages

Before using a package in LaTeX, we should check it is installed on our system. Most LaTeX distributions, such as TeX Live and MiKTeX, include a package manager. This manager helps to install new packages easily.

We can commonly employ the package manager’s graphical user interface or the command line interface to install a package. In TeX Live, for example, we can use the following command in the terminal:

sudo tlmgr install <package_name>

Where <package_name> is the package name we want to install. It is important to note that we must have administrator privileges to install packages.

3. Loading Packages in LaTeX

Once installed, we need to load the package into our LaTeX document for using it. The straightforward way to do this is by using the \usepackage command in the document’s preamble. The preamble is the document section before the \begin{document} command.

The syntax for the \usepackage command follows:


The options argument is optional and is employed to specify any options for the package. The <package_name> argument is the name of the package we want to load.

4. A Package Usage Example

After understanding how to install and load packages in LaTeX, let’s see a simple example of how to use a package. In particular, we’ll use the graphicx package in our example.

The graphicx package manipulates graphics, such as images, in LaTeX. It provides multiple commands to access images stored in a location of our system and insert them in LaTeX documents.

An example of such commands is the \includegraphics one. The command next inserts the image indicated by the image_path in a LaTeX document:


Moreover, the graphicx package also provides multiple options for controlling the size and position of the image. For instance, the following command scales an image to a specific width:


Let’s consider the image next as the standard input for the following examples:

Baeldung image


The following command inserts an image with a specified height:


The output should be as follows:

Baeldung image output


The following command inserts an image with a width equal to 50% of the text width:


The output image should be visibly 50% smaller (in terms of width) than the reference image:

output image

The following command rotates an image by 90 degrees:


After using such a command, the output should be rotated 90 degrees compared to the reference image as follows:

rotated image


5.  Conclusion

In this article, we learned how to install, load, and use packages in LaTeX. We exemplified such processes through a practical example with a frequently utilized package.

We can easily add more functionality to our LaTeX documents and develop professional-looking documents by using packages. The vast number of available packages emphasizes the flexibility and power of LaTeX as a document preparation system.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.