Related to this question. How to reduce the default gap between the two side by side images ? Thank you in advance.
Asked
Active
Viewed 3,225 times
0
1 Answers
4
There's no gap between images. The gap is due to the size of each image inside every subfigure.
In Gonzalo's answer, every subfigure occupies half text line, but the image inside every subfigure only uses 40% of available space. This creates the gap.
Following code shows the original answer and another where images inside subfigure use the whole available space. And there is no gap!
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{example-image}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{example-image}
\caption{A subfigure}
\label{fig:sub2}
\end{subfigure}
\caption{A figure with two subfigures}
\label{fig:test}
\end{figure}
\begin{figure}
\centering
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{A subfigure}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\caption{A subfigure}
\label{fig:sub2}
\end{subfigure}
\caption{A figure with two subfigures}
\label{fig:test}
\end{figure}
\end{document}
Ignasi
- 136,588

subfigure/minipageenvironments. But the images inside those environments are much narrower than the width of the environment, so there is a gap between the images. So in that sense there is no default gap, it depends on how large your images are compared to theminipage/subfigurethey're in, and also any space between theminipages/subfigure`s. – Torbjørn T. Mar 14 '18 at 07:51subfigure/minipage, so make onesubfigurea bit wider, the other narrower by the same amount. – Torbjørn T. Mar 14 '18 at 12:54