4

I'm using a quite satisfying solution for figures with side by side images with subcaption, a solution by which images are sized automatically to same height and to text width, see MWE below.

\documentclass{article}
\usepackage{mwe}
\usepackage{floatrow}
\usepackage{subcaption}

\begin{document}
\blindtext

\begin{figure*}[htb]
\ffigbox{}{\CommonHeightRow{\begin{subfloatrow}[2]% this comment needed, see 1st comment to question
\ffigbox[\FBwidth]{\includegraphics[height=\CommonHeight]{example-image-10x16}}{\caption{A subcaption.}\label{fig:01a}}
\ffigbox[\FBwidth]{\includegraphics[height=\CommonHeight]{example-image-16x10}}{\caption{Another subcaption.}\label{fig:01b}}
\end{subfloatrow}}
\caption{The composite figure caption.}\label{fig:01a+01b}}
\end{figure*}

\blindtext
\end{document}

enter image description here

However sometimes I would like to limit the overall width of the two figures to something less (say 80%) than text width (retaining the uniform height), but I couldn't find a way to achieve it. A very nice solution to a similar problem does not seem to work in this case.

Thanks in advance for any clue.

Solutions using a package other than floatrow are welcomed, as long as they automatically size images height and overall width by a given percentage of text width, as required.

P.S. I just noticed a slight shift of figure to the right, maybe some floatrow package expert can help to fix this too.

mmj
  • 1,702
  • 2
    The shift to the right is due to an unprotected space at the end of the line. Where you have \begin{subfloatrow}[2] add a comment character at the end of the line: \begin{subfloatrow}[2]% and the space will be gone. See this for an explanation on spaces at the end of the lines. – Phelype Oleinik May 25 '18 at 19:28

1 Answers1

6

width of ffigbox you can determine with option width:

\ffigbox[<width>][<height<][<vert pos<]{<caption>}{<object>}

in your case try:

\documentclass{article}
\usepackage{mwe}
\usepackage{floatrow}
\usepackage{subcaption}

\begin{document}
\blindtext

\begin{figure*}[htb]
\ffigbox[0.8\linewidth]{}{\CommonHeightRow{\begin{subfloatrow}[2]%
\ffigbox[\FBwidth]{\includegraphics[height=\CommonHeight]{example-image-10x16}}{\caption{A subcaption.}\label{fig:01a}}
\ffigbox[\FBwidth]{\includegraphics[height=\CommonHeight]{example-image-16x10}}{\caption{Another subcaption.}\label{fig:01b}}
\end{subfloatrow}}
\caption{The composite figure caption.}\label{fig:01a+01b}}
\end{figure*}

\blindtext
\end{document}

enter image description here

is this what you looking for?

Zarko
  • 296,517