LaTeX Figures¶
Quick Links
Figure with Caption¶
\begin{figure}[H]
\centering
\includegraphics[height=1in]{NASA_Logo}
\caption{Figure with Caption}
\label{fig:nasa-logo}
\end{figure}
Two Figures with Two Captions¶
Hint
Note that the actual figure environment logic in this example is no different than the simple single example shown above. We are simply utilizing the minipage environment in order to create temporary sections within our document to place images. In the example below, we create two minipage environments each occupying half the page as denoted by 0.5\textwidth. This same logic can be extended to any layout the user wants!
\begin{minipage}[c]{0.5\textwidth}
\begin{figure}[H]
\centering
\includegraphics[height=1in]{NASA_Logo}
\caption{NASA Logo}
\label{fig:nasa-logo}
\end{figure}
\end{minipage}%
\begin{minipage}[c]{0.5\textwidth}
\begin{figure}[H]
\centering
\includegraphics[height=1in]{Artemis_Logo}
\caption{Artemis Logo}
\label{fig:artemis-logo}
\end{figure}
\end{minipage}
Two Figures with One Caption¶
\begin{figure}[H]
\centering
\includegraphics[height=1in]{NASA_Logo}%
\hspace{1in}% add some horizontal spacing
\includegraphics[height=1in]{Artemis_Logo}%
\caption{Two Figures with One Caption}
\label{fig:nasa-and-artemis-logo}
\end{figure}
Sub-Figures with Sub-Captions¶
\begin{figure}[H]
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[height=1in]{NASA_Logo}
\caption{NASA Logo}
\label{fig:nasa-logo}
\end{subfigure}%
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[height=1in]{Artemis_Logo}
\caption{Artemis Logo}
\label{fig:artemis-logo}
\end{subfigure}%
\caption{Sub-Figures with Sub-Captions}
\label{fig:nasa-and-artemis-logos}
\end{figure}
Referencing Figures¶
The example below highlights how the \label command is used to define a unique label to this specific figure and how it can be referenced within the text of the document using the \ref command.
\begin{figure}[H]
\centering
\includegraphics[height=1in]{NASA_Logo}
\caption{Figure with Caption}
\label{fig:nasa-logo}
\end{figure}
The NASA logo can be seen in \ref{fig:nasa-logo}.
Also note how the "Figure" prefix is automatically added within the document text whenever the reference is called.
Referencing Sub-Figures¶
The example below highlights how the \ref command operates exactly the same on subfigure as it does on figure environment.
\begin{figure}[H]
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[height=1in]{NASA_Logo}
\caption{NASA Logo}
\label{fig:nasa-logo}
\end{subfigure}%
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[height=1in]{Artemis_Logo}
\caption{Artemis Logo}
\label{fig:artemis-logo}
\end{subfigure}%
\caption{Sub-Figures with Sub-Captions}
\label{fig:nasa-and-artemis-logos}
\end{figure}
The logos used in this document can be found in \ref{fig:nasa-and-artemis-logos}.
\ref{fig:nasa-logo} displays the NASA logo and \ref{fig:artemis-logo} displays the Artemis logo.
Referencing Range of Figures¶
The example below highlights how the \refrange command can be used to reference a range of figures.
\begin{minipage}[c]{0.33\textwidth}
\begin{figure}[H]
\centering
\includegraphics[height=1in]{NASA_Logo}
\caption{NASA Logo}
\label{fig:nasa-logo}
\end{figure}
\end{minipage}%
\begin{minipage}[c]{0.33\textwidth}
\begin{figure}[H]
\centering
\includegraphics[height=1in]{Artemis_Logo}
\caption{Artemis Logo}
\label{fig:artemis-logo}
\end{figure}
\end{minipage}
\begin{minipage}[c]{0.33\textwidth}
\begin{figure}[H]
\centering
\includegraphics[height=1in]{Orion_Logo}
\caption{Orion Logo}
\label{fig:orion-logo}
\end{figure}
\end{minipage}
\vspace{\baselineskip}
We can reference a range of figures as seen here: \refrange{fig:nasa-logo}{fig:orion-logo}.
Also note how the "Figures" prefix is automatically added within the document text whenever the range reference is called.