# Simulating a figure-environment

Is it possible to place two figure environments evenly side-by-side at the same horizontal height with some text between them ?

In this question of mine, a partial solution has been provided to me, namely by provide a command that takes two pictures and places them evenly (across the horizontal) and allows for some text between them.

Here's the code of it, for those who don't want to follow the link (there's picture there too!):

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

\begin{center}
\raisebox{\dimexpr-.5\height+.5\ht\strutbox}%
{\includegraphics[width=1in,height=1in]{black_square}}%
\hspace{.5in}%
and%
\hspace{.5in}%
\raisebox{\dimexpr-.5\height+.5\ht\strutbox}%
{\includegraphics[width=1in,height=1in]{black_square}}
\par\end{center}

Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text Text Text Text Text Text Text Text Text Text Text Text Text
Text Text
\end{document}


What I would like to do is to add some text below each picture, like "Figure : ", as if two figure-environments were places side-by-side, so that the number of the figure is reference-able.

• Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jun 21 '14 at 9:01
• The accepted answer in the link I provided contains the code I put here as a MWE. Since my question is how to modify this MWE as described, I can't add a MWE that "illustrates my problem" (if I interpreted your request correctly). – l7ll7 Jun 21 '14 at 9:18
• No, I meant a framework such that other users do not have to build it up themselves ;-) – user31729 Jun 21 '14 at 9:22
• @ChristianHupfer Well, the only way I know how to do that would be by manual distance adjustment for some specific pictures (via trial and error, i.e. playing sufficiently long with \hspace{xpt} and \vpspace{ypt} for some numbers x,yuntil it fits), which would be a waste of my time doing it and your time reading it. While I applaud your intentions, in this case they don't seem to be applicable. – l7ll7 Jun 21 '14 at 10:11
• @user10234: I have the impression, that you still misunderstand my intention: Just post a \documentclass{...}, the relevant \usepackage statements and \begin{document}...\end{document}, so that other users here willing to help you do not have to do that tedious stuff. – user31729 Jun 21 '14 at 10:43

Without any special package, you can use 1 figure float with 3 minipages. If you want simulate that are two different figures, simply add two captions inside the minipages of the images (see MWE). If you want the images numbered as subfigures, take a look to the subfig and subcaption packages.

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage[margin=2cm]{geometry}
\usepackage{kantlipsum} % for dummy text
\begin{document}
\kant[1] %dummy text
\begin{figure}[htb]
\begin{minipage}{.25\linewidth}
\includegraphics[width=\linewidth]{example-image-9x16}
\caption{One nice left figure.}
\end{minipage}\hfill%
\begin{minipage}{.35\linewidth}
\kant[2]
\end{minipage}\hfill%
\begin{minipage}{.25\linewidth}
\includegraphics[width=\linewidth]{example-image-9x16}
\caption{Another nice on the right.}
\end{minipage}
\end{figure}
\kant[3] % dummy text
\end{document}

• Thanks, your answer seems to be exactly what I need. But before I award ou the bounty, could please also tell me, how I can insert a small horizontal space to the left of the left figure (or graphic) and to the right of the right figure (or graphic), so that the figures (or graphics) are bit more on the interior of the page than the outmost border of the text. – l7ll7 Oct 6 '14 at 10:29
• Is it also possible to align the left figure to the right of its minibox (an analogously the right figure to the left of the minibox) ? – l7ll7 Oct 6 '14 at 10:30
• @user10324 For the first, you can reduce the minipages to .2\linewidth ,for example, and then use \hspace{.05\linewidth} just before the first minipage and just after the last minipage (be careful, without adding extra spaces (end lines with %to be sure). For the second is nearly the same: reduce the width of the left image and then add \hfill (\raggedleft must work also) just before \includegraphics inside the minipage. Reduce the width of the right image is enough. OK? – Fran Oct 6 '14 at 16:06

Try this

\documentclass[draft]{article}
\usepackage{graphicx,caption}
\usepackage[latin]{babel}
\def\lorem{\raggedright Fusce adipiscing justo. Nullam in enim.
Pellentesque felis orci. }
\begin{document}
\begingroup
\parindent0pt
\fboxsep1pt\fboxrule0.4pt
\hsize=3cm\footnotesize
\hfil\fbox{\vbox to 5cm{\vfill
\includegraphics[width=\hsize]{./images/amato}
\vfill
}}
\hfil\fbox{\vbox to 5cm{\vfill\lorem\lorem\lorem\par\vfill}}%
\hfil\fbox{\vbox to 5cm{\vfill\includegraphics[width=\hsize]{./images/amato}\vfill}}\hfill
\endgroup
\captionof{figure}{Output to demonstrate the use of vboxes.}
\end{document}


You can automate this by measuring the height of the boxes and programming everything in a macro. This is a quick and dirty solution.

Adjust the centering using the \hfil or \hfill (see second example below)

\documentclass[draft]{article}
\usepackage{graphicx,caption}
\usepackage[latin]{babel}
\def\lorem{\raggedright Fusce adipiscing justo. Nullam in enim.
Pellentesque felis orci. }
\begin{document}
\begingroup
\parindent0pt
\fboxsep1pt\fboxrule0.4pt
\hsize=3cm\footnotesize
\fbox{\vbox to 5cm{\vfill
\includegraphics[width=\hsize]{./images/amato}
\vfill
}}
\hfill\fbox{\vbox to 5cm{\vfill\lorem\lorem\lorem\par\vfill}}%
\hfill\fbox{\vbox to 5cm{\vfill\includegraphics[width=\hsize]{./images/amato}\vfill}}
\endgroup
\captionof{figure}{Output to demonstrate the use of vboxes.}

\lorem\lorem\lorem\lorem\lorem\lorem
\end{document}


You only need a single floating environment to manage the construction. Apart from that you can use almost anything to construct the inner parts. I've used tabularx to make a tabular that fits within the text block width:

\documentclass{article}
\usepackage{lipsum,tabularx,capt-of}
\usepackage[margin=2cm]{geometry}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\begin{document}
\lipsum[1]
\begin{figure}[htb]
\begin{tabularx}{\linewidth}{
@{\hspace{0pt}}% Space between left margin and left figure
L% Alignment of left figure
@{\hspace{\tabcolsep}}% Space between left figure and middle text
C% Alignment of middle text
@{\hspace{\tabcolsep}}% Space between middle text and right figure
R% Alignment of middle text
@{\hspace{0pt}}}% Space between right figure and right margin
\includegraphics[width=\linewidth,valign=t]{example-image-9x16}
\captionof{figure}{One nice left figure.}
&
\lipsum[2]
&
\includegraphics[width=\linewidth,valign=t]{example-image-9x16}
\captionof{figure}{Another nice on the right.}
\end{tabularx}
\end{figure}
\lipsum[3]
\end{document}


Adjustments can be made in terms of the alignment (vertically and/or horizontally) for each of the three cells. I've placed them in a column of type L, C and R, which currently is Left (\raggedright), Centre (\centering) and Right (\raggedleft) aligned.

Space between columns and margins can also be adjusted with the above setup (clearly indicated).