[Tex/LaTex] Vertical alignment with floatrow

floatrowfloatsvertical alignment

I am playing with floatrow, however the images are not aligned at the top and I do not know what I am doing wrong.

\begin{figure}[H]
\begin{floatrow}
\floatbox{figure}[0.4\textwidth][\FBheight][t]
{\caption{first image positioned at the top}
 \label{fig:floatrow:example:3:a}}
{\includegraphics[width=0.25\textwidth]{images/TestBild.png}}
%
\floatbox{figure}[0.4\textwidth][\FBheight][t]
{\caption{second image positioned at the top}
 \label{fig:floatrow:example:3:b}}
{\includegraphics[width=0.2\textwidth]{images/TestBild.png}}
\end{floatrow}
\end{figure}

also I would like to add a defined spacing between the pictures, but have not found out how. Typically I add either \hspace{2em} or \hfill, but both do nothing if inserted between the commands (as expected).

Best Answer

You can use the option heightadjust=object for \floatsetup, as I did in the following example:

\documentclass[10pt]{article}
\usepackage{floatrow}
\usepackage[demo]{graphicx}

\floatsetup{heightadjust=object}

\begin{document}

\begin{figure}
\begin{floatrow}
\floatbox{figure}[.4\textwidth][\FBheight][t]
{\caption{first image positioned at the top}
 \label{fig:floatrow:example:3:a}}
{\includegraphics[width=0.25\textwidth,height=7cm]{images/TestBild.png}}\hspace*{1cm}
%
\floatbox{figure}[.4\textwidth][\FBheight][t]
{\caption{second image positioned at the top}
 \label{fig:floatrow:example:3:b}}
{\includegraphics[width=0.2\textwidth]{images/TestBild.png}}
\end{floatrow}
\end{figure}

\end{document}

I used the demo option for the graphicx package to replace the images with black rectangles; do not use that option in your actual code.

enter image description here

Related Question