This question follow up from other solutions (like this one) that solve the problem of automatically sizing, given a total width, two side by side images (different in size and aspect ratio, which may have a single caption or one caption each) in a figure environment, so that they have the same height. I would like to do the same with the only difference that the two images should have the same area instead of the same height.
In fact, placing side by side two images of same height having very different aspect ratio gives often unsatisfactory results, whereas, if they have the same area, the appearance is aesthetically much more pleasant.
Here is a MWE of the starting code (same height images):
\documentclass{article}
\usepackage{mwe}
\usepackage{xcolor}
\usepackage{floatrow}
\usepackage{subcaption}
% 2 side by side images with a single caption
% arguments: image 1, image 2, caption, width (as ratio of textwidth)
\newcommand{\figureonepp}[4]{%based on Figure 103 at pag. 100 of floatrow manual
\begin{figure*}[htbp]%
\ffigbox[#4\textwidth]{}{\CommonHeightRow{\begin{subfloatrow}[2]% this comment needed, otherwise an unprotected space shifts slightly the figure to the right
\ffigbox[\FBwidth]{\includegraphics[height=\CommonHeight]{#1}}{}
\ffigbox[\FBwidth]{\includegraphics[height=\CommonHeight]{#2}}{}
\end{subfloatrow}}
\caption{#3}}
\end{figure*}}
% define allowable width used by floatrow package
% usage example (put at beginning of figure, before any floatrow command): \ThisWidth{0.8\textwidth}
\makeatletter
\def\ThisWidth#1{%
\@tempdima\dimexpr(\textwidth-#1)/2\relax
\edef\FRleftmargin{\noexpand\hspace*{\the\@tempdima}}%
\edef\FRrightmargin{\noexpand\hspace*{\the\@tempdima}}%
\ignorespaces}
\makeatother
% two side by side images each one with a caption
% arguments: image 1, image 2, caption 1, caption 2, width (as ratio of textwidth)
\newcommand{\figuretwopp}[5]{%
\begin{figure*}
\ThisWidth{#5\textwidth}
\CommonHeightRow{\begin{floatrow}
\ffigbox[\FBwidth]{\includegraphics[height=\CommonHeight]{#1}}{\caption{#3}}
\ffigbox[\FBwidth]{\includegraphics[height=\CommonHeight]{#2}}{\caption{#4}}
\end{floatrow}}
\end{figure*}}
\begin{document}
\pagecolor{yellow!10}
\blindtext
\figureonepp{example-image-10x16}{example-image-16x10}{This is the figure caption.}{0.8}
% uncomment the following line to show the two captions case
%\figuretwopp{example-image-10x16}{example-image-16x10}{Left caption.}{Right caption.}{0.8}
\blindtext
\end{document}
The above code produces the page on the left (same height images), while the desired result (same area images) is shown on the right:
I guess that the solution should implement some kind of \CommonAreaRow macro to be used in place of \CommonHeight.
Although the question is different, the code in this answer may be of some help.
Thanks in advance for any help.


\edef\tmpvs{\fpeval{0.5*(\tmpx*\ht0+\tmpy*\ht1)}}, but I'm not able to use the result, I guess I'm missing something about units of measure. – mmj Mar 17 '20 at 10:48\CenterFloatBoxes, so this one does not have to be computed explicitly. (And I now David, people from this region are known for their politeness. ;-) (Just kidding. ;-) – Mar 17 '20 at 11:40\CenterFloatBoxesafter\begin{subfloatrow}, perfect, thanks! – mmj Mar 17 '20 at 11:4812ptgap size come from? Is it possible to change it? – mmj Mar 17 '20 at 23:29\columsep. You can change it with, say,\columnsep=4pt. I updated the answer accordingly. – Mar 17 '20 at 23:37