How to change(or scale) size of figure(image) in LaTeX?

I think figure resizing is an important method of LaTeX. By small and large any original size figure can be adjusted with other elements(text, list, table) and inserted anywhere in the document.

As a result, you can create clear and well-organized documents or papers. Because it is true that you also want document to be beautiful and well formatted.

You need to have clarity on length variables and \includegraphics command to become a master at figure resizing.

Length Variables

You may think, what is length variable? The length variable is a predefined set of latex commands that represent the full width and height of page, minipage, and multicolumn layouts.

You can control the width and height by using the length variable as a percentage.

Suppose, width of figure is 70 percent of total text area. Then width will be (70/100)\textwidth = .7\textwidth.

Syntax of \includegraphics

The \includegraphics command in LaTeX is used to insert images into your document. It is part of graphicx package, which is one of the most commonly used packages for handling images in LaTeX.

Before you use \includegraphics command, you need to include graphicx package in your document preamble with \usepackage{graphicx} command.

\includegraphics[option]{file name or location path}

This option represents an optional argument with which you can control many things, including changing the size of a figure.

Name of figure file pass in main argument and location path must be passed in the argument if figure file is located in a folder.

Set width and height as a fraction of textwidth

\textwidth refers to width of text on the page. This is the width of body of page, excluding margins.

If you use \includegraphics[width=0.5\textwidth]{image}, your image will be scaled to occupy 50% of the text width on the page.

\documentclass[12pt]{article}
\usepackage{graphicx,lipsum,xcolor}
\usepackage[margin=1.5cm]{geometry}
\begin{document}
\pagecolor{red!10!white}


\section*{Width resize but the aspect ratio is also maintained}
\lipsum[1][1-3]
\begin{figure}[ht]
\centering
    \includegraphics[width=.8\textwidth]{image.jpg}
    \caption{Width is 80 percent. However, the aspect ratio is also maintained.}
\end{figure}

\section*{Height resize but the aspect ratio is also maintained}
\lipsum[2][1-4]

\begin{figure}[ht]
\centering
    \includegraphics[height=.4\textwidth]{image.jpg}
    \caption{height is 40 percent. However, the aspect ratio is also maintained.}
\end{figure}

\lipsum[3][1-8]

\section*{Change width and height together, default aspect ratio will not be maintained}

\lipsum[5][1-8]

\begin{figure}[ht]
\centering
    \includegraphics[width=.8\textwidth, height=.8\textwidth]{image.jpg}
    \caption{Width and height as a Fraction of Text Width}
\end{figure}

\lipsum[7]

\section*{Change width and height together. But, keepaspectratio is added}

\lipsum[9][1-5]

\begin{figure}[ht]
\centering
    \includegraphics[width=.8\textwidth, height=.8\textwidth,keepaspectratio]{image.jpg}
    \caption{Width and height as a fraction of textwidth but aspect ratio fixed}
\end{figure}

\end{document}

Output :

Figure 1: Width of the figure is specified to be 80% of total text width (0.8\textwidth) of page. The height automatically adjusts to ensure the original aspect ratio of figure is maintained.

Figure 2: For this figure, only height is defined, set to 40% of total text width (0.4\textwidth) of page. Width of image is then automatically adjusted to keep the original aspect ratio.

Figure 3: Here, both the width and height of image are defined to be 80% of text width. Without any directive to maintain the original aspect ratio, the image will be forced into these dimensions.

Figure 4: In the final figure, the image is again set to occupy a width and height of 80% of text width. However, with the addition of keepaspectratio option, the image ensures that its original proportions are maintained.

Its actual width or height (depending on the original image’s proportions) might be less than the specified 0.8\textwidth.

Set width relative to linewidth of figure

\linewidth is similar to \textwidth, but it refers to width of line in its current environment.

\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{graphicx,multicol, caption, xcolor}
\usepackage{lipsum} % for dummy text
\begin{document}
\pagecolor{green!10!white}

\lipsum[1][1-4] % Some dummy text

\begin{figure}[h]
    \centering
    \includegraphics[width=1\linewidth]{example-image-duck} 
    \caption{An example image scaled to 100\% of the line width}
\end{figure}

\lipsum[2][1-6] % Some more dummy text

\begin{multicols}{2}
 \centering
   \includegraphics[width=.99\linewidth]{example-image-duck}
   \captionof{figure}{An example image scaled to 99\% of first column.}
   \columnbreak
   \includegraphics[width=.99\linewidth]{example-image-duck}
   \captionof{figure}{An example image scaled to 99\% of second column.}
\end{multicols}

\lipsum[3]

\begin{multicols}{2}
 \centering
   \includegraphics[width=.99\linewidth, height =.99\linewidth]{example-image-duck}
   \captionof{figure}{width 99 \% and height 99\%}
   \columnbreak
   \includegraphics[width=.99\linewidth, height=.8\linewidth]{example-image-duck}
   \captionof{figure}{width 99\% and height 80\%}
\end{multicols}

\lipsum[4][1-8]

\begin{figure}[ht]
\centering
\begin{minipage}{.5\textwidth}
  \includegraphics[width=1\linewidth]{example-image-duck}
  \caption{width 100\% of minipage}
\end{minipage}%
\begin{minipage}{.5\textwidth}
  \includegraphics[width=1\linewidth, height=.7\linewidth]{example-image-duck}
  \caption{width 100\% and height 70\%}
\end{minipage}
\end{figure}

\end{document}

Output :

Figure 1: Figure is scaled to match full width of line (1\linewidth), taking up the entire available space within the text area. Its height adjusts automatically to maintain the original aspect ratio.

Figures 2 and 3 (multicols ): These figures lie within a two-column layout, and each image occupies 99% of the width of its respective column. \linewidth here refers to the width of the column in multicols environment, not overall text width of page.

Figures 4 and 5 (multicols): Again set within a two-column layout, images in this section have specified dimensions. The first image occupies 99% of column width and 99% of the column height, which might cause it to stretch or compress vertically depending on the original image’s aspect ratio.

Figures 6 and 7 (minipage): Here, two minipage environments are used side-by-side, each occupying half text width (0.5\textwidth). In the first minipage, figure is scaled to fill the entire width, with its height automatically adjusting to maintain the aspect ratio.

Second minipage houses an image that’s also scaled to full width, but its height is specifically set to be 70% of the minipage width.

Set width and height Relative to columnwidth (in Two-Column Layout)

\columnwidth will represent the current column width. Whether your document contains one or more columns.

\documentclass[12pt,twocolumn]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{graphicx,xcolor,multicol,lipsum,caption}

\begin{document}
\pagecolor{yellow!30}

\lipsum[1][1-8] % Some dummy text to fill the columns

\lipsum[2][1-6]

\begin{figure}[ht]
    \centering
    \includegraphics[width=1\columnwidth]{image.jpg}
    \caption{An example image scaled relative to the column width.}
\end{figure}

\lipsum[1]

\begin{figure}[ht]
    \centering
    \includegraphics[width=.9\columnwidth]{image.jpg}
    \caption{An example image scaled relative to the column width.}
\end{figure}

\lipsum[2]

\begin{figure}[ht]
    \centering
    \includegraphics[width=.9\columnwidth, height=.8\columnwidth]{image.jpg}
    \caption{An example image scaled relative to the column width.}
\end{figure}

\lipsum[2][3-4]

\onecolumn

\lipsum[4]

\begin{multicols}{2}
 \centering
   \includegraphics[width=.95\columnwidth]{image.jpg}
   \columnbreak
   \includegraphics[width=.95\columnwidth]{image.jpg}
\end{multicols}

\begin{multicols}{3}
 \centering
   \includegraphics[width=.95\columnwidth]{image.jpg}
   \columnbreak
   \includegraphics[width=.95\columnwidth]{image.jpg}
   \columnbreak
   \includegraphics[width=.95\columnwidth]{image.jpg}
\end{multicols}

\lipsum[7]

\end{document}

Output :

In the output, notice that the entire document is first split into two columns. Figures are added on both sides. And with respect to width of column, width and height of figure are adjusted.

Notice below that, two and three columns are created by the multicols environment and a figure is inserted in each column. In this case, the width of each image is kept at the same percentage with respect to width of column.

Using scale option of \includegraphics command

Instead of representing width and height separately or together, you can scale an image by a factor of its original size using the scale option. For example

\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{graphicx,lipsum,xcolor}

\begin{document}
\pagecolor{green!7!white}

\section*{Scaled Images in LaTeX}

\lipsum[1][1-6]

\begin{figure}[h]
    \centering
    \includegraphics[scale=2]{example-image-duck}
    \caption{Scale 2 times of original size}
\end{figure}

\lipsum[2][1-6]

\begin{figure}[h]
    \centering
    \includegraphics[scale=1.5]{example-image-duck}
    \caption{Scale 1.5 times of original size}
\end{figure}

\lipsum[3]

\begin{figure}[h]
    \centering
    \includegraphics[scale=.3]{image.jpg}
    \caption{Image scaled to .3 times of its original size}
\end{figure}

\end{document}

Output :

Set absolute width and height (Aspect Ratio Not Preserved) of figure

If a constant value is used instead in the length variable, the aspect ratio will not be maintained.

And you also can’t get the right idea, that one figure will occupy how much space of your page or minipage or column. Because in this case the figure is not being inserted with respect to the width of the other element.

\documentclass[12pt]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{graphicx,lipsum,xcolor}

\begin{document}
\pagecolor{brown!20}

\section*{First Image with Text}

\lipsum[1][1-4]

\begin{figure}[ht]
    \centering
    \includegraphics[width=10cm, height=7cm]{example-image-duck} 
    \caption{First example image with fixed width and height}
\end{figure}

\section*{Second Image with Text}

\lipsum[2][1-4]

\begin{figure}[ht]
    \centering
    \includegraphics[width=13cm, height=8cm]{example-image-duck} 
    \caption{Second example image with fixed width and height}
\end{figure}

\section*{Third Image with Text}

\lipsum[3][1-8]

\begin{figure}[ht]
    \centering
    \includegraphics[width=7cm, height=7cm]{example-image-duck} 
    \caption{Third example image with fixed width and height}
\end{figure}

\lipsum[4][1-8]

\end{document}

Output :

Best practice for figure resize

1. If the document structure is one column, the best practice is to use textwidth.

2. If the document structure is multicolumn or minipage, use \linewidth or \columnwidth in that case.

3. For each method above, change the width and height of the figure separately, then aspect ratio will be maintained. However, aspect ratio will not be maintained when changing simultaneously.

Conclusion

Not only inserting figures but also adjusting the size of figures with other elements to create beautiful documents is an art. Which is explained very nicely in this tutorial. There are many methods, but you should always try to choose the best practice.

Md Jidan Mondal

LaTeX expert with over 10 years of experience in document preparation and typesetting. Specializes in creating professional documents, reports, and presentations using LaTeX.

Leave a Comment

Your email address will not be published. Required fields are marked *