3

I would like to arrange four images in a similar style to this code taken slightly modified from Four Arranged Figures are offset .

\documentclass{article}
\usepackage[demo]{graphicx} % leave off demo option in real program
\renewcommand{\thefigure}{\alph{figure}}
\begin{document}


\begin{figure}    
\begin{minipage}[t]{0.5\textwidth}
\includegraphics[width=\linewidth]{a.pdf}
\caption{a)}
\label{fig:immediate}
\end{minipage}

\begin{minipage}[t]{0.5\textwidth}
\includegraphics[width=\linewidth]{b.pdf}
\caption{b)}
\label{fig:proximal}
\end{minipage}


\begin{minipage}[t]{0.5\textwidth}
\includegraphics[width=\linewidth]{c.pdf}
\caption{c)}
\label{fig:distal}
\end{minipage}

\begin{minipage}[t]{0.5\textwidth}
\includegraphics[width=\linewidth]{d.pdf}
\caption{d)}
\label{fig:combined}
\end{minipage}

\end{figure}
\end{document}

My images are mostly white so I would like them to touch but to add a vertical and horizontal line in a cross shape to separate them. The two lines should cross in the middle and stretch to the top and bottom and left and right of the images respectively.

Simd
  • 6,785

1 Answers1

3

We can achieve this by using subcaption.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\begin{document}


\begin{figure}
  \subcaptionbox{caption}{\includegraphics[width = 2in]{a}}\quad
  \subcaptionbox{caption}{\includegraphics[width = 2in]{b}}\\
  \subcaptionbox{caption}{\includegraphics[width = 2in]{a}}\quad
  \subcaptionbox{caption}{\includegraphics[width = 2in]{b}}
\end{figure}
\end{document}

enter image description here


If you want to caption the 4 subfigures, add \caption{caption} below the lase \subcaptionbox. This will then call this figure 1: caption

enter image description here


To separate the figures with a line, we can use the tabular environment.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption, tabu}
\begin{document}
\begin{figure}
  \begin{tabular}{c|c} %vertical line I added | between cc
  \subcaptionbox{caption}{\includegraphics[width = 2in]{a}}&
  \subcaptionbox{caption}{\includegraphics[width = 2in]{b}}\\
  \hline
  \subcaptionbox{caption}{\includegraphics[width = 2in]{a}}&
  \subcaptionbox{caption}{\includegraphics[width = 2in]{b}}
  \end{tabular}
  %\caption{caption} %this is the caption for the whole figure delete % in front of caption if you want it.
\end{figure}
\end{document}

enter image description here

At present, the demo graphic butts up against the bounding box, but since you figures are mostly white, as you stated, the line should be seen without blending into the picture as with the demo.

David Carlisle
  • 757,742
dustin
  • 18,617
  • 23
  • 99
  • 204
  • Thank you. I have a few questions. I can use \subcaptionbox{}{\includegraphics[width = 2in]{a}} to get rid of the caption text but how can I move the (a), (b) etc. vertically? Also, I am not sure how to add the vertical/horizontal thin separating line. ([demo] needs a white counterpart for this too.) – Simd Aug 12 '13 at 19:04
  • Yes I would like to be able to move it right up to the picture or even onto it. My picture is mostly white as I say. – Simd Aug 12 '13 at 19:11
  • @Lembik there is an opening question on that right now:subfigures with number inside figure I don't know if the answer works but you can try it or wait for someone to pose another answer that is accepted. – dustin Aug 12 '13 at 19:15
  • Thanks. Is there an equivalent vertical line? – Simd Aug 12 '13 at 19:19
  • The current answer at http://tex.stackexchange.com/questions/127853/subfigures-with-number-inside-figure doesn't seem to move the caption vertically sadly. The answer looks like it is at http://tex.stackexchange.com/questions/45990/how-can-i-modify-vertical-space-between-figure-and-caption but \setlength{\belowcaptionskip}{0pt} has no effect for me. – Simd Aug 12 '13 at 19:49
  • Making this a separate question. – Simd Aug 12 '13 at 19:55
  • I am not sure it is the same question. I just want to change the space between the images and the subcaptions. – Simd Aug 12 '13 at 20:05
  • My problem is the vertical space between the images and the subcaptions. Can I add {c@{\vspace{xcm}}c} somewhere to change that? – Simd Aug 12 '13 at 20:10
  • Sorry for being confusing. I would like to reduce the space between all the images and their respective subcaptions. – Simd Aug 12 '13 at 20:15
  • @Lembik make the value negative. – dustin Aug 12 '13 at 20:15
  • That just moves the horizontal line doesn't it? For example, changing the [1cm] to [-0.5cm] doesn't move the subcaptions any nearer to the images. It also doesn't change anything about the bottom two subcaptions unless I am missing something. – Simd Aug 12 '13 at 20:19
  • I understand now. It probably can be done but I am don't know off the top of my head. – dustin Aug 12 '13 at 20:20