LaTEX Tutorials

Figures in LaTeX

1. How to insert figures in LaTeX?

Figures  are important part of scientific documents.  The package required for including figures in your document is ‘graphicx‘. Therefore, add \usepackage{graphicx} command before the begin document command.

There are five important points you must remember when you include a figure in LaTeX document. 

  1. Creating the figure environment

You can include figures in your document by creating the ‘figure’ environment. It is achieved using the following commands. 

         \begin{figure} 

         \end{figure} 

  1. Align the figure at center

To justify the figure at the center, we can use \centering command before the \includegraphics command. 

  1. Inserting the figure

Then, inside the figure environment, you can include the figure using the command \includegraphics{} where you can specify the filename along with the file location. 

              \includegraphics[scale=0.6]{images\myphoto.jpg} 

  1. Providing a Caption

An important part of each figure is its caption, we can add figure caption by using the command \caption{} after the \includegraphics{} command. 

  1. Setting the label name

Another important point to remember when you include a figure in latex is to provide a label_name which uniquely identify each figure inserted in the document. We use \label{} to provide a label to the figure. 

 Finally, when you include all the instructions to the figure, it looks like this. 

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}

\begin{figure}[htb]
\centering
\includegraphics[width=\linewidth]{Sample_image.jpg}
\caption{A dummy image for figure environment}
\label{fig1}
\end{figure}

\end{document}

How to place the figures in the document?

For placing the figure at a particular location, you can specify the location by providing [htb] after the \begin{figure}. It means that place the figure here (h), or place the figure at the top(t), or place the figure at the bottom (b). If you use [!h], which means to place forcefully here. Also, we can use [H] to place the figure at this place. However, [H] is more powerful than [!h]. 

Scaling the figure size:

You can use [width=\linewidth] to fit the figure in the page. Another useful and import technique is to use scale, where you can change the resolution to properly adjust the figure in the document. It is like [scale=0.5] or [scale=0.75]. 

 

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}

\begin{figure}[htb]
\centering
\includegraphics[scale=0.2]{Sample_image.jpg}
\caption{A dummy image for figure environment}
\label{fig11}
\end{figure}

\end{document}

How to place the figures in the document?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Diam in arcu cursus euismod quis viverra nibh cras pulvinar. Vulputate ut pharetra sit amet aliquam. Orci a scelerisque purus semper eget duis at tellus. Quam nulla porttitor massa id neque aliquam vestibulum morbi. Enim neque volutpat ac tincidunt. Nibh nisl condimentum id venenatis a condimentum. Non curabitur gravida arcu ac tortor dignissim convallis. Libero id faucibus nisl tincidunt eget. Viverra justo nec ultrices dui. Ultrices dui sapien eget mi proin sed libero enim. Et netus et malesuada fames ac turpis. Gravida rutrum quisque non tellus orci ac auctor. Cursus vitae congue mauris rhoncus aenean. Aliquet lectus proin nibh nisl condimentum id venenatis a condimentum.

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}

\begin{figure}[htb]
\centering
\begin{subfigure}[b]{0.4\linewidth}
\includegraphics[width=\linewidth]{Sample_image.jpg}
\caption{Image 1}
\end{subfigure}

\begin{subfigure}[b]{0.4\linewidth}
\includegraphics[width=\linewidth]{Sample_image.jpg}
\caption{Image 2}
\end{subfigure}

\caption{Combining multiple images as a single figure}
\label{fig3}
\end{figure}

\end{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Diam in arcu cursus euismod quis viverra nibh cras pulvinar. Vulputate ut pharetra sit amet aliquam. Orci a scelerisque purus semper eget duis at tellus. Quam nulla porttitor massa id neque aliquam vestibulum morbi. Enim neque volutpat ac tincidunt. Nibh nisl condimentum id venenatis a condimentum. Non curabitur gravida arcu ac tortor dignissim convallis. Libero id faucibus nisl tincidunt eget. Viverra justo nec ultrices dui. Ultrices dui sapien eget mi proin sed libero enim. Et netus et malesuada fames ac turpis. Gravida rutrum quisque non tellus orci ac auctor. Cursus vitae congue mauris rhoncus aenean. Aliquet lectus proin nibh nisl condimentum id venenatis a condimentum.

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}

\begin{figure}[htb]
\centering
\begin{subfigure}[b]{0.4\linewidth}
\includegraphics[width=\linewidth]{Sample_image.jpg}
\caption{Image 1}
\end{subfigure}

\begin{subfigure}[b]{0.4\linewidth}
\includegraphics[width=\linewidth]{Sample_image.jpg}
\caption{Image 2}
\end{subfigure}

\begin{subfigure}[b]{0.4\linewidth}
\includegraphics[width=\linewidth]{Sample_image.jpg}
\caption{Image 3}
\end{subfigure}

\begin{subfigure}[b]{0.4\linewidth}
\includegraphics[width=\linewidth]{Sample_image.jpg}
\caption{Image 4}
\end{subfigure}

\caption{Multiple images are combined together as single image file}
\label{fig4}
\end{figure}

\end{document}

Need Help?

If you need any further clarification or assistance in LaTeX coding, you are free to contact us.