I'm searching for a MWE to get equal distances between text and all environments in my document.
Equal distances mean in this case:
Distance between text and the upper border of the environment
Distance between caption and text
In the attached MWE, you can see that there are always other distances. So how can I fix it?
\documentclass[fontsize=12pt,twoside=false,]{scrbook}
\usepackage[ngerman]{isodate,babel}
\usepackage{listings}
\usepackage{float}
\usepackage{caption}
\usepackage{hhline}
\usepackage{ltablex}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{blindtext} % Just for the MWE
\DeclareCaptionType{equ}[][]
\setlength\parindent{0pt}
\begin{document}
%Listing with and without minipage environment
\blindtext
\begin{minipage}[t]{\linewidth}
\begin{lstlisting}[captionpos=b,caption={[Listing]{Listing}}]
Code Code Code
\end{lstlisting}
\end{minipage}
\blindtext
\blindtext
\begin{lstlisting}[captionpos=b,caption={[Listing]{Listing}}]
Code Code Code
\end{lstlisting}
\blindtext
\newpage
%Tabularx environment
\blindtext
\begin{tabularx}{\textwidth}{|l|p{33mm}|l|>{\arraybackslash}X|}
\hline
\endfirsthead
Test & Test & Test & Test\\
\hline
\caption[Tabularx]{Tabularx}
\end{tabularx}
\blindtext
\newpage
%Figure environment
\blindtext
\begin{figure}[H]
\centering
\includegraphics[width=3cm]{example-image}
\caption{Figure}
\end{figure}
\blindtext
\newpage
%Equation environment
\blindtext
\begin{equ}[!ht]
\begin{equation}
a=b+c
\end{equation}
\caption{Caption of the equation}
\end{equ}
\blindtext
\end{document}
This question seems to be similar to this one, but asks for more environments.




Example.jsonis not available. – leandriis Oct 03 '19 at 13:41minipage? Do you have some special reason? From MWE i don't see this. I wouldn't putlistinginminipage. – Zarko Oct 04 '19 at 14:15minipageto prevent line breaks within the listings. – PascalS Oct 04 '19 at 14:17minipage,minipagecan leave a lot of empty spaces on previous page (when is moved to the next page) . However i such a cases you cam manually correct vertical distances, for example as:\begin{minipage}t]\linewidth}\vspace{-0.5\baselineskip} \begin{lstlisting}[captionpos=b,caption={[Listing]{Listing}}] Code Code Code \end{lstlisting} \end{minipage}– Zarko Oct 04 '19 at 14:23\vspace{}command. Is there a macro with defines the space skip of the minipage? – PascalS Oct 04 '19 at 14:28[t]atminipage. You will have to wait for an expert to answer your . – Zarko Oct 04 '19 at 14:32