How to embed a subfigure inside another subfigure

I have multiple plots which I built using Tikz. I need to put all of them in the next configuration. Can anyone give me an idea of how to do it?

• Do you want captions there? If not, you can use tabular with 2 rows and 2 columns and insert image in each cell. – Sigur Feb 22 '19 at 18:55
• I added more information. Important, each plot was done using Tikz. – John Fontecha Feb 22 '19 at 19:00

Like this? (adjustment on figures widths are needed)

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}[h]\centering
\subfloat[faa]{\label{fig.a}\includegraphics[width=.45\linewidth]{example-image-a}}
\hfill
\subfloat[fbb]{\label{fig.b}\includegraphics[width=.45\linewidth]{example-image-b}} \\
%%
\subfloat[fcc]{\label{fig.c}\includegraphics[width=.45\linewidth]{example-image-c}}
\hfill
\subfloat[fdd]{\label{fig.d}
\begin{tabular}[b]{@{}c@{}}
\includegraphics[width=.225\linewidth]{example-image-b}%
\includegraphics[width=.225\linewidth]{example-image-b}\\[-3pt]
\includegraphics[width=.225\linewidth]{example-image-b}%
\includegraphics[width=.225\linewidth]{example-image-b}
\end{tabular}%
}
\caption{global}\label{fig.global}
\end{figure}
\end{document}

• can the \includegraphics be replaced by the Tikz code? – John Fontecha Feb 22 '19 at 19:13
• Yes, but I recommend you to create separated pdf for each TikZ figure, using the standalone class. So you don't need to compile such code every time. It make your document process faster, and make the code clearer. – Sigur Feb 22 '19 at 19:14
• In your solution, you are setting up the size using width=0.45, however, that is part of the \includegraphics options. How can you setting up the size using the plot code? Thank you very much for your help! – John Fontecha Feb 22 '19 at 19:17
• @JohnFontecha, one more reason to create separated images. – Sigur Feb 22 '19 at 19:18

Just to demonstrate that there are multiple ways to do things. Note that every subfigure is a glorified minipage, and every image (box) is treated just like a single letter in a line of text. (\subfloat puts the contents into a savebox, then put both the savebox and the caption into a minipage.)

Also, minipages change the values of \textwidth and \linewidth inside the environment. BTW, \lineskip is the minimum vertical separation between the bottom of one line and the top of the next (as opposed to \baselineskip, which is the minimum separation between baselines).

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{showframe}% MWE only
\begin{document}
\begin{figure}[h]\centering
\begin{subfigure}{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{faa}\label{fig.a}
\end{subfigure}%
\hfill
\begin{subfigure}{.45\linewidth}% glorified minipage
\includegraphics[width=\linewidth]{example-image-b}
\caption{fbb}\label{fig.b}
\end{subfigure}%
\\
\begin{subfigure}{.45\linewidth}% glorified minipage
\includegraphics[width=\linewidth]{example-image-c}
\caption{fcc}\label{fig.c}
\end{subfigure}%
\hfill
\begin{subfigure}{.45\linewidth}% glorified minipage
\lineskip=0pt
\includegraphics[width=0.5\linewidth]{example-image}%
\includegraphics[width=0.5\linewidth]{example-image-a}\\
\includegraphics[width=0.5\linewidth]{example-image-b}%
\includegraphics[width=0.5\linewidth]{example-image-c}
\caption{fdd}\label{fig.d}
\end{subfigure}
\caption{global}\label{fig.global}
\end{figure}
\end{document}