Contents

Inserting Images

Images are often needed to clarify explanations in articles, reports, worksheets, and scientific writing. In LaTeX\LaTeX, you can insert external image files and then control their size, position, rotation, and relationship to surrounding text.

Before inserting an image, keep these points in mind:

  • add the graphicx package in the preamble,
  • store the image file in the same folder as the document or use the correct path,
  • use \caption{...} when the image needs a caption.
\usepackage{graphicx}

If you are working in Overleaf, upload the image file into the same project first.

[

Uploading image files in Overleaf
Uploading image files in Overleaf
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHhoFNwj0hn9VUP2H2ICPzu6qxpdgzbHpUajYMUqJv5lQ1j3INW5471G7Gq3-lhRr47xRQ51a3nFMqqx63ITrRTC5ZIlfor6lLbXm512Sd-up96kIlyZDd7_LNhXClNuQF-UaotAQbWLo/s1119/blog1.png)

The simplest example looks like this:

\begin{figure}[h]
  \centering
  \includegraphics[width=0.5\textwidth]{image.png}
  \caption{Example image}
\end{figure}

[

Single image example in LaTeX
Single image example in LaTeX
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifuX7XwDbRjKR7n3ErnrxzAMltKG76OJiGPzFoHymH4_zttCNldzuDXA3mWFYN8imyQDjVBYnw1y8spVzWcnWJ9CGbdnKlbA_oOxLnzNqN8o7k7xNLTFfRz6cCJLm2_kr4yfS06lyeCj8/s1198/gambar1.png)

To show multiple images in one section, you can place multiple \includegraphics commands together.

\begin{figure}[h]
  \centering
  \includegraphics[width=0.35\textwidth]{image1.png}
  \includegraphics[width=0.35\textwidth]{image2.png}
  \caption{Two images in one figure}
\end{figure}

[

Two images example in LaTeX
Two images example in LaTeX
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb5h2Xz6S_79NmBkWJwAoW2cdba9-qDOyLhHvyV6yvvqjoUXGq6VUtyXdnQ0Cg47D_H-NmndYj66Q4xBbKxCRaJiNDSkrah3bhTheHvhyphenhyphen8Rn5nKZQJFw5tc0JPLyJo8MP50SQAqv3Girc/s984/gambar2.png)

Common options include:

  • \includegraphics[scale=...]{image}
  • \includegraphics[width=...,height=...]{image}
  • \includegraphics[width=...]{image}
  • \includegraphics[width=\textwidth]{image}

Example:

\includegraphics[width=0.6\textwidth]{image.png}

You can rotate an image with the angle option.

\includegraphics[width=0.4\textwidth,angle=45]{image.png}

[

Rotated image example in LaTeX
Rotated image example in LaTeX
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgS3IwrbRw9ecjH33_uLfN_T6wqvWoN4zP5Ry5U_BLZliUzO9xCUszWz9STNhzSl3_oFyI5mKUnhYv74lkaKRcMLtbUy_Yst_HOoOUm63x7S50hXITkLY5PVX1YbeerFtqjeigCX2sQko0/s982/gambar3.png)

To control spacing between images, you can use horizontal and vertical spacing commands such as \quad or \baselineskip.

\includegraphics[width=0.3\textwidth]{image1.png}
\quad
\includegraphics[width=0.3\textwidth]{image2.png}

[

Image alignment example in LaTeX
Image alignment example in LaTeX
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQATYTkDEaoPSwj1zuHeGxJ2tZV_ZEsxETYohPRlLY9FDCWe2vn1u6Af_DS9q5SwCjP5o_O07w2MN7vCmx3FV3yAXM-Wdk7XW61GnsGTCcbKZEGrnbpZC7CebSeGoRd3OcQKMjVWPno1A/s1212/gambar4.png)

Images are usually placed inside the figure environment.

\begin{figure}[h]
  \centering
  \includegraphics[width=0.5\textwidth]{image.png}
  \caption{Image at a chosen position}
\end{figure}

[

Image position example in LaTeX
Image position example in LaTeX
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwCmh5Vkr_QrRLFRdvxR2JUNqmF4kaHEEiQeY5j5EvUVxRAazo1Q6Fl8V1FuS5BtjbfwBXVVAb7lGPrhaThqKYm97I4nl3Rc-xpu19L5UV1E04QSZW2MmaBtJ9In2J_Rp_6rd7P5ICbFA/s1212/gambar5.png)

Common placement options for \begin{figure}[...]:

  • h: here
  • t: top
  • b: bottom
  • p: special float page
  • !: force the placement more strongly
  • H: place it exactly here, usually with the float package

For alignment:

  • \centering centers the image,
  • \flushleft aligns it left,
  • \flushright aligns it right.

If readers need to compare several images, use subfigures or subcaptions.

\usepackage{subcaption}

\begin{figure}[h]
  \centering
  \begin{subfigure}{0.45\textwidth}
    \includegraphics[width=\linewidth]{image1.png}
    \caption{First image}
  \end{subfigure}
  \begin{subfigure}{0.45\textwidth}
    \includegraphics[width=\linewidth]{image2.png}
    \caption{Second image}
  \end{subfigure}
  \caption{Two subfigures}
\end{figure}

[

Subfigure example in LaTeX
Subfigure example in LaTeX
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivIX6w-i5Dn3XfaLIA8l5aH1y8WPhn8vtefe9mjDYMF2mUN7zc9LeYWOh3bnG_Hf0vPUNoO3IlYaMBopXgoFrz3LjMv4XTL89FLMLbQPkSu9d9fReEKJU2HjijwY86jXJpDTmi2IKVfsM/s1223/gambar01.png)

To place an image beside a block of text, minipage is a practical option.

\begin{minipage}{0.45\textwidth}
  \includegraphics[width=\linewidth]{image.png}
\end{minipage}
\hfill
\begin{minipage}{0.45\textwidth}
  Write the explanation here.
\end{minipage}

[

Minipage example in LaTeX
Minipage example in LaTeX
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4VhHQKPchF6WtGQRDqNlwee0sGpYwdR8gEGiRdn7zHe7rTm7oohla1s3XttnsXCnHvDksBiUavpEtl04g_Q1aurgt20jff9in6x2GXeTF2LKPBp_sfk_r8wVUjoLYPd-NhvLsB-NEi1Y/s1233/gambar7.png)

If you want text to wrap around an image, use the wrapfig package.

\usepackage{wrapfig}

\begin{wrapfigure}{r}{0.4\textwidth}
  \includegraphics[width=\linewidth]{image.png}
\end{wrapfigure}

[

Wrapfig example in LaTeX
Wrapfig example in LaTeX
](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoPap1kLQDcrVOy63X_CFfzUL6GdkJCQGpY8lsZJr9KXVS_oPDl1205f-Qk7ioQjj4VkgkK6Vbnnok3CSGkIaIWencKAxpjmudTssI7tAaHSDBwxQxd9OvwaJpL1XC1MKdu3YbKxfCXsM/s1082/gambar8.png)

Those are some of the most common ways to insert images in LaTeX\LaTeX. With graphicx and supporting environments such as figure, subfigure, minipage, and wrapfig, image layout becomes much more flexible and easier to manage.

Related Content