# Fully customized figure template - align figures and text (captions) at will

I would like to manipulate subfigures and captions exactly as I want. The result I want to obtain is visible just below:

I want to display Image 1 at 0.8\textwidth (the width/height ratio will always be the same). Then I want to add the caption below on the left as shown, with multiple lines (either the text does not fit in one line OR I have to make a new line).

Finally, Image 2 belongs to the lower right corner with a fixed height and width (expressed in terms of textwidth or in pts it does not matter). Ideally I would like to add a frame around Image 2 that respects the overall template (the frame lines should stay within the general rectangle).

Here is some code I tried that is the closest to this template but still not close enough :

\begin{figure}[htb]
\subfloat{\includegraphics[width=0.8\textwidth]{Image_1}}\par
\parbox[][][t]{0.6\textwidth}{\RawCaption{\caption{both_images_title\\both_images_source}}}
\subfloat{\includegraphics[width=0.2\textwidth, height=0.15\textwidth]{image_2}}
\end{figure}


With this code the images are well placed (still no frame to Image 2), and while the Figure numbering is good, the text weirdly hangs at the bottom, and is horizontally centered.

Thanks for helping if you wish,

Keep in touch.

• Welcome to TeX.SE. Please, always add a Minimal Working Example. Snippets of code doesn't work well here since they depend of classes and/or other packages. When a result you have isn't as you intended, please also add an image, then explain what is not as you'd like it to be. That said, there are a few packages to deal with it, including caption, subcaption and subfigure. You seem to be using subfloat. You may also have to use the environment minipage.
– FHZ
Jun 25 at 16:36

OPTION 1 This solution uses \usepackage[export]{adjustbox} to adjust the boxes content and to draw the frame for the second figure. The keyvalue export allows to include the options in \includegraphics

\documentclass[12pt,a4paper]{article}

\usepackage{graphicx}

\usepackage{caption}
\captionsetup[figure]{% caption set up
format=hang,
width=0.5\linewidth,
font=sf,
singlelinecheck=false
}

\begin{document}

\begin{figure}
\includegraphics[width=0.8\textwidth, valign=b]{example-image-a}
\begin{minipage}[t]{0.5\linewidth}
\vspace{-0.8\baselineskip}  % adjust vertical sep
\caption{some text plus both images title and images source and more text that fits in another line.}
\end{minipage}\hspace*{\dimexpr -1.2ex-3pt+0.1\linewidth} % adjust horizontal sep
\adjustbox{fbox =3pt 0pt}{\includegraphics[width=0.2\linewidth,valign=t]{example-image}} % box with 3pt rule and  0pt separation
\end{figure}

\end{document}


OPTION 2

Another option to accurately align objects is using the package tikz.

You define three nodes: the first with the wide image, the second with the smaller (framed) one, and the third with the caption. Then align the last two with respect to the first.

\documentclass[12pt,a4paper]{article}

\usepackage{graphicx}

\usepackage{caption}
\captionsetup[figure]{% caption set up
format=hang,
font=sf,
singlelinecheck=false
}

\usepackage{tikz}%<<<<<<<<<<<<<<<
\usetikzlibrary {positioning}

\begin{document}

\begin{figure}
\begin{tikzpicture}
\node [inner sep=0] (a) {\includegraphics[width=0.8\linewidth]{example-image-a}};
\node [draw, red, line width= 3pt, inner sep=0, anchor= north east] at (a.south east) {\includegraphics[width=0.2\linewidth]{example-image}};
\node [inner sep=0, above=2mm of a, text width=0.5\linewidth,anchor= north west,align=justify] at (a.south west)
{\caption{some text plus both images title and images source and more text that fits in another line.}};
\end{tikzpicture}
\end{figure}

\end{document}

• Tried option A which gave the same result as the one you show, thanks! Although as a perfectionist there is this small gap between Image 1 and Image 2. I will try Option B (which looks promising) very soon to see the difference. To be continued. Jun 26 at 16:51
• Option B is great, very flexible, exactly what I was looking for. Thank you! Jun 27 at 7:47