I have an image in my document that I want to display as big as possible in landscape orientation but the whole figure (image AND caption) should be within the limits of the body.
I researched a lot how to define the size for the whole figure environment and the most suggested solution was to replace the figure by a minipage. However, I don't get the result I want to have.
MWE for the minipage approach:
\documentclass[a4paper, DIV=13, 12pt]{scrreprt}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{pdflscape}
\usepackage{lipsum}
\title{This is the Title}
\author{It's a Me, Mario!}
\begin{document}
\maketitle
\chapter{Chapter}
\lipsum[6]
\begin{landscape}
\begin{minipage}[t][\textheight][t]{\linewidth}
\centering
\noindent\includegraphics[height=\textheight,keepaspectratio]{example-image-a}
\captionof{figure}{This is the long version of the description of the caption}
\label{fig:flussdiagramm}
\end{minipage}
\end{landscape}
\chapter{Chapter}
\lipsum[5]
\end{document}
But the problem stays the same: The caption is outside of the body. Here's what I mean:

The margin of the caption (red arrow) does not match the margin of the other pages (blue arrows).
I thought, that a minipage redefines the \textheight and \linewidth but it seems that this is not the case. Can anybody confirm this?
How can I make sure, that the caption is within the body/text area and the margins stay the same on each page?
Best, Korbinian

\includegraphics[height=\textheight,the image will be full height and not leave room for a caption – David Carlisle Apr 12 '23 at 11:24I saw some solutions where people calculate the height but is this really the easiest way/best practice for this?
– Korbinian Hutter Apr 12 '23 at 11:28@Others: I did the calculation with Frank Mittelbach's answer (first code block) on this post: https://tex.stackexchange.com/a/47185/261955
It worked for me. You can also keep the figure environment and don't need a minipage.
– Korbinian Hutter Apr 12 '23 at 13:57Can anybody confirm this?
– Korbinian Hutter Apr 13 '23 at 14:15