Figures

Code snippets for figures:

 

Standard figure
%Preamble
\usepackage{graphicx}

%Document
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth]{figure.png}
\caption[short for lof]{long figure caption}
\label{fig:default}
\end{figure}
\ref{fig:default}

 

Side-by-side figure (1×2)
%Preamble
\usepackage[lofdepth]{subfig}
\usepackage{graphicx}

%Document
\begin{figure}[htbp] % h:here; t:top; b:bottom; p:page; default:ht
\centering
 \subfloat[short for lof][long subfigure1 caption]{
   \includegraphics[width=0.45\linewidth]{figure1.png}
   \label{subfig:fig1}
 }
 \subfloat[short for lof][long subfigure2 caption]{
   \includegraphics[width=0.45\linewidth]{figure2.png}
   \label{subfig:fig2}
}
\caption[short for lof]{long figure caption}
\label{fig:fig1}
\end{figure}
\ref{fig:fig1} and \subref{subfig:fig1}

 

Side-by-side figure (2×2)
%Preamble
\usepackage[lofdepth,lotdepth]{subfig}
\usepackage{graphicx}

%Document
\begin{figure}[ht]
\centering
 \subfloat[short for lof][long subfig1 caption]{
   \includegraphics[width=0.45\linewidth]{figure1.png}
   \label{subfig:fig1}
 }
 \subfloat[short for lof][long subfig2 caption]{
   \includegraphics[width=0.45\linewidth]{figure2.png}
   \label{subfig:fig2}
}

 \subfloat[short for lof][long subfig3 caption]{
   \includegraphics[width=0.45\linewidth]{figure3.png}
   \label{subfig:fig3}
 }
 \subfloat[short for lof][long subfig4 caption]{
   \includegraphics[width=0.45\linewidth]{figure4.png}
   \label{subfig:fig4}
}
\caption[short for lof]{long figure caption}
\label{fig:fig1}
\end{figure}
\ref{fig:fig1} and \subref{subfig:fig1}

 

Sideways-figure
% Preamble
\usepackage{rotating}

% Document
\begin{sidewaysfigure}
\centering
\includegraphics{figure.png}
\caption{Sideways figure.}
\label{fig:swfig}
\end{sidewaysfigure}

 

Wrap text around figure
%Preamble
\usepackage{wrapfig, graphicx}

% Document
\begin{wrapfigure}{l}{0.5\textwidth} % l for left, r for right
\centering
\includegraphics[width=0.45\textwidth]{test}
\caption{Text wrapped around figure}
\label{fig:wrapfig}
\end{wrapfigure}