2

The code below by Simon Dispa in my previous post creates a very nice table and image staying together. However, it is not float. I'm looking for something like this but float.
If I just use two separate floats table and figure then there is still a chance for them to be splitted. Therefore, I'm looking for something like one float.

enter image description here

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{tabularray}
\usepackage{booktabs,capt-of}
\usepackage{lipsum}


\begin{document}

\lipsum[1]
\noindent\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}
            \footnotesize %<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
            \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}
    \vspace*{\baselineskip} %<<<<<<<<<<<<<<<
    \end{minipage}
\lipsum[1]
\end{document}   

                 

2 Answers 2

4

I suggest you (a) use a single figure environment and (b) place a minipage environment (of width \columnwidth) below the image and associated caption to house the table and its \capt-of directive.

enter image description here

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{tabularray}
\usepackage{capt-of}
\usepackage{lipsum}

\begin{document}
\lipsum[1][1-6] % filler text

\begin{figure}[h]
     \includegraphics[width=\columnwidth]{example-image-a}
     \caption{A figure}
     \label{fig:a_figure}

     \begin{minipage}{\columnwidth}   
     \centering  
     \captionof{table}{A table}
     \label{tab:a_table}
     
     \footnotesize
     \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{figure}

\lipsum[1][1-6] % more filler text
\end{document} 
1
  • Nice, I saw this idea but thought that they should be the same type like two figures or two tables.
    – emnha
    Sep 13, 2022 at 21:30
2

This is a general approach that defines a new float with its caption.

  • It can have any content: tables, figures, tikzpictures,...
  • It will work with other classes, as article or report.
  • Uses the package newfloat and the customization offered by tocloft.
  • It is capable of generating the list of new floats similar to listoffigures.

Using \documentclass[journal]{IEEEtran}

ieee

z

With

\documentclass[twocolumn]{article}
\usepackage[left=2.00cm, right=1.50cm,top=1cm]{geometry}

art

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .