How can I make sure that the table is always just below the figure and they always go together?
Each should have its own caption and the caption follows IEEEtrans as in the image.
In the code below it works but I think there is no constraint to make that they are always next to each other.
EDIT: I want to glue the figure and table together and place them on a corner of a page instead of putting them inside the text.
\documentclass[journal]{IEEEtran}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{blindtext}
\begin{document}
\blindtext[1]
\begin{figure}[!t]
\centering
\includegraphics[width=0.9\linewidth]{example-image-a}
\caption{A figure}
\label{fig:a figure}
\end{figure}
%
\begin{table}[!t]
\centering
\caption{A table}
\label{tab:a table}
\begin{tabular}{ r@{}c@{}l r@{}c@{}l r@{}c@{}l r@{}c@{}l } % 12 columns
\toprule
\multicolumn{6}{c}{\textbf{SET 1}} &\multicolumn{6}{c}{\textbf{SET 2} } \\
\cmidrule(rl){1-6} \cmidrule(rl){7-12}
\multicolumn{3}{c}{A long name} & &B& & &C& &\multicolumn{3}{c}{A longer name} \\ %changed <<<<<<<<<<<
\midrule
$\mathrm{X_{A}}$ &$\leftrightarrow$ &$\mathrm{X_B}$ & $\mathrm{X_{A}}$ &$\leftrightarrow$ &$\mathrm{X_B}$ & $\mathrm{X_{A}}$ &$\leftrightarrow$ &$\mathrm{X_B}$ & $\mathrm{X_{A}}$ &$\leftrightarrow$ &$\mathrm{X_B}$ \\
$\mathrm{Y_{CD}}$ &$\leftrightarrow$ &$\mathrm{Y_N}$ & $\mathrm{Y_{CD}}$ &$\leftrightarrow$ &$\mathrm{Y_N}$ & $\mathrm{Y_{CD}}$ &$\leftrightarrow$ &$\mathrm{Y_N}$ & $\mathrm{Y_{CD}}$ &$\leftrightarrow$ &$\mathrm{Y_N}$ \\
$\mathrm{Z_{CDE}}$ &$\leftrightarrow$ &$\mathrm{Z_K}$ &&& &&& &&& \\
&A.4& & && & & & && \\
&A.5& & && & & & && \\
\bottomrule
\end{tabular}
\end{table}
\end{document}