When I put the table and figure in two separate enviroments, they fit nicely to one column like this.
However, when I put them in minipage as one float the figure and table become misaligned and the table is bigger than the \linewidth
.
How can I fix this? I want to put them into one float with two separate captions like that.
\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{tabularray}
\usepackage{booktabs,capt-of}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
%
\begin{table}[!t]
\centering
\caption{a table}
\label{tab:a table}
\begin{tblr}{
colspec={Q[2.35em,c] *7{Q[2.34em,c]}},
vline{1} = {2-Z}{0.8pt},
vline{2,Z} = {0.8pt},
vline{3-Y} = {0.3pt},
hline{1} = {2-Z}{0.8pt},
hline{2,Z} = {0.8pt},
hline{3-Y} = {0.3pt},
row{1-8} = {mode=math},
column{1-8} = {mode=math},
}
& V_1 & V_2 & V_3 & V_4 & V_5 & V_6 & V_7\\
V_1 & & 1 & 0 & 0 & 1 & 0 & 1\\
V_2 & 1 & 0 & 1 & 0 & 1 & 0 & 1\\
V_3 & 0 & 1 & 0 & 1 & 0 & 0 & 1\\
V_4 & 0 & 0 & 1 & 0 & 1 & 0 & 1\\
V_5 & 1 & 1 & 0 & 1 & 0 & 0 & 1\\
\end{tblr}
\end{table}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{a figure}
\label{fig:my_label}
\end{figure}
\lipsum[1]
\lipsum[1]
\begin{minipage}{\linewidth}
\begin{minipage}[b]{\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\label{fig:a figure}
\captionof{figure}{a figure}
\end{minipage}
\hfill
\begin{minipage}[b]{\linewidth}
\captionof{table}{a table}
\label{tab:a table}
\begin{tblr}{
colspec={Q[2.35em,c] *7{Q[2.34em,c]}},
vline{1} = {2-Z}{0.8pt},
vline{2,Z} = {0.8pt},
vline{3-Y} = {0.3pt},
hline{1} = {2-Z}{0.8pt},
hline{2,Z} = {0.8pt},
hline{3-Y} = {0.3pt},
row{1-8} = {mode=math},
column{1-8} = {mode=math},
}
& V_1 & V_2 & V_3 & V_4 & V_5 & V_6 & V_7\\
V_1 & & 1 & 0 & 0 & 1 & 0 & 1\\
V_2 & 1 & 0 & 1 & 0 & 1 & 0 & 1\\
V_3 & 0 & 1 & 0 & 1 & 0 & 0 & 1\\
V_4 & 0 & 0 & 1 & 0 & 1 & 0 & 1\\
V_5 & 1 & 1 & 0 & 1 & 0 & 0 & 1\\
\end{tblr}
\end{minipage}
\end{minipage}
\lipsum[1]
\end{document}