I want to put four figures in a single row. The code I am trying to use is taken from http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions.
This puts three figures in a row. When I add a fourth one, I get three images in row and the last one appears in the second row. But I want all of them in one row. Here is my code.
\documentclass[12pt,twoside]{report}% Use this line for the print version of the thesis
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{gull}
\caption{A gull}
\label{fig:gull}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{gull}
\caption{A gull2}
\label{fig:gull2}
\end{subfigure}%
~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
%(or a blank line to force the subfigure onto a new line)
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{tiger}
\caption{A tiger}
\label{fig:tiger}
\end{subfigure}
~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
%(or a blank line to force the subfigure onto a new line)
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{mouse}
\caption{A mouse}
\label{fig:mouse}
\end{subfigure}
\caption{Pictures of animals}\label{fig:animals}
\end{figure}
\end{document}
As I have mentioned above, it works for three figures. But I can not use it for four figures. What should I change?
What does width=\textwidth
mean?
I changed
\begin{subfigure}[b]{0.3\textwidth}
to
\begin{subfigure}[b]{0.2\textwidth}
but it didn't help.
Then, I changed
\includegraphics[width=\textwidth]{mouse}
to
\includegraphics[width=0.5\textwidth]{mouse}
Still no solution.





\centeringinstructions inside thesubfigureenvironments since you're setting the graphs to occupy the full widths available.0.22\textwidth.