[Tex/LaTex] How to get sidewaysfigure to stay on specific page

floatsgraphicsminipagerotating

I have a rather large figure which I want to put in the appendix. Further, I want this figure to appear sideways (landscape mode). I have been trying with the following code which gives me exactly what I want except the image keeps showing up on the next page and not on the page which has the appendix section title and which is the page I want it to appear on. This means that now I have the appendix title on an otherwise empty page followed by the figure on the next page. If I use figure instead of sidewaysfigure it works just fine although I want the image in landscape mode and not in portrait mode.

I have tried to change \begin{sidewaysfigure}[htbp] to \begin{sidewaysfigure}[h!] and \begin{sidewaysfigure}[H] etc. without any luck. I have also tried reducing the size of the figure but even though it reduces in size it does not move up on the previous page. It seem to me the issue is with `begin{sidewaysfigure} but I might be completly wrong.

Any help is much appreciated!

\documentclass[a4paper, 12pt, hidelinks]{article}
\usepackage{fancyhdr}
\usepackage[pdftex]{graphicx} 
\usepackage{rotating}


\begin{document}
\newpage
\appendix
\section{Impulse Responses}
    \begin{sidewaysfigure}[htbp]
        \centering
        \begin{minipage}{0.92\linewidth}
            \includegraphics[width=\linewidth,keepaspectratio]{test1.pdf}
            \caption{Impulse Responses}
            \vspace{0.2cm}
            \emph{\footnotesize Note:} {\footnotesize The impulse responses.} 
        \end{minipage}
        \label{fig:xx}
    \end{sidewaysfigure}

\end{document}

Best Answer

Use a simple sideways environment and \captionof{figure}:

\documentclass[a4paper, 12pt, hidelinks]{article}
\usepackage{fancyhdr}
\usepackage[pdftex, demo]{graphicx}
\usepackage{rotating, float, caption}

\begin{document}
\newpage
\appendix

\section{Impulse Responses}
 \mbox{} \begin{center}
    \begin{sideways}%[htbp]
         \begin{minipage}{0.92\linewidth}
                    \includegraphics[width=\linewidth,keepaspectratio]{test1.pdf}
                    \captionof{figure}{Impulse Responses}
         \vspace{0.2cm}
         \emph{\footnotesize Note:} {\footnotesize The impulse responses.}
         \label{fig:xx}
         \end{minipage}
    \end{sideways}
    \end{center}

\end{document} 

enter image description here