Latex Image Examples: Sizing, Positioning, Captioning, etc

Latex Image Examples: Sizing, Positioning, Captioning, etc

Last updated:
Table of Contents

Reduce space after image captions

\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{path/to/image.png}
\caption{\textit{ImageCaption}}
\vspace{-1.5em}
\end{figure}
This is first

Center image

Use \centering.

Additionally, note how we configure the image to be as wide as the text with [width=\textwidth].

\begin{figure}[!h]
    \centering
    \includegraphics[width=\textwidth]{path/to/image.png}

    \caption{Lorem impsum}
    \label{fig:myimage}
\end{figure}

Two images side-by-side

\begin{figure}[!h]
    \begin{subfigure}{0.5\textwidth}
        \centering
    \includegraphics[width=0.8\textwidth]{path/to/image1.png}
    \caption{Caption for image 1}
    \end{subfigure}
    \begin{subfigure}{0.5\textwidth}
        \centering
    \includegraphics[width=0.8\textwidth]{path/to/image2.png}
    \caption{Caption for image 2}
    \end{subfigure}
    \caption{This is goes at the end, after both images}
\end{figure}

Force image to be exactly where you define it

Use [H] modifier:

\begin{figure}[H]
    \includegraphics{path/to/image.png}
    \caption{Lorem impsum}
\end{figure}

References