# Keeping section headers and rotated images on the same page

I have a similar problem like the one here:

Problems with landscape mode and Title on the same page

Unfortunately, I'm trying to include images, which doesn't seem to work this way.

I've tried the following as proposed in one of the answers to the question above:

\documentclass{article}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{booktabs}
\usepackage{hvfloat}

\begin{document}

\section{Test Section with Several Rotated Objects}

\hvFloat[%
nonFloat=true,%
capWidth=w,%
capPos=t,%
rotAngle=90,%
objectPos=c%
]\begin{figure}
\centering
\setlength\fboxsep{0pt}
\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[scale=0.5,trim=33 355 137 50, clip=true]{image1}
\includegraphics[scale=0.5,trim=55 135 65 135, clip=true]{image2}}
\caption{caption.}
\label{img:caption}
\end{figure}
\end{document}


But this returns the error:

! Argument of \caption@ydblarg has an extra }.
<inserted text>
\par
l.12    \setlength
\fboxsep{0pt}


Could someone point me in the right direction, please? Thanks.

Please read the documentation of hvfloat as you have not used anything of it's syntax.

The source for your example should be:

% arara: pdflatex

\documentclass{article}
\usepackage[a6paper]{geometry}% just for the example
\usepackage[demo]{graphicx}
\usepackage{hvfloat}

\begin{document}
\section{Test Section with Several Rotated Objects}
\hvFloat[%
nonFloat=true,%
capWidth=w,%
capPos=t,%
rotAngle=90,%
objectPos=c%
]{figure}{%
\setlength\fboxsep{0pt}
\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[scale=0.5,trim=33 355 137 50, clip=true]{image1}
\includegraphics[scale=0.5,trim=55 135 65 135, clip=true]{image2}}
}{caption.}{img:caption}
\end{document}