0

How can I make table expand over many pages?
I got some suggestion on longtable but couldn't make it work for this case. The code below can only display the table in one page only. I need to expand the table over many pages.

enter image description here

\documentclass[journal]{IEEEtran}
\usepackage{amsmath,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{array}
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
%\usepackage{textcomp}
\usepackage{stfloats}
\usepackage{url}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{cite}
\usepackage{booktabs,capt-of}
\usepackage{newtxtext, newtxmath}
\usepackage{array}
\usepackage{parskip}
\usepackage{mathtools}

\begin{document}

 \begin{table*}[!t]
  \centering
  \caption{}
  \label{}
  \begin{tabular}{c|c|c|c}
                            \toprule
\textbf{No} &\textbf{C1}  &\textbf{C3}&\textbf{C4} \\\midrule
1    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule

2    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule
3    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule

4    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule
5    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule

6    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule
7    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule

8    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule
9    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule

10    & \begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-a}

  \label{fig:first}
\end{minipage}%
\hfill % maximize the horizontal separation
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-b}

  \label{fig:second}
\end{minipage}%
\hfill
&\begin{minipage}[t]{0.3\textwidth}
  \includegraphics[width=\linewidth]{example-image-c}

  \label{fig:third}
\end{minipage}\\\midrule

\end{tabular}

\end{table*} 

\end{document}
4
  • @Rmano can you tell me what is confusing? It's a table with many rows and you can think all rows' contents are same. I just checked the link you sent and tried it with my ieeetran class but I got an error saying that longtable is not in 1-column mode.
    – hana
    Jul 8, 2022 at 16:39
  • I am not sure that longtable can work with two columns document.
    – Rmano
    Jul 8, 2022 at 18:57
  • @Rmano is there any solution to this problem? Would supertabular work?
    – hana
    Jul 8, 2022 at 19:27
  • @Rmano it's two column format but the table expands on both columns, does that make any difference?
    – hana
    Jul 9, 2022 at 2:21

1 Answer 1

2
  • In your case, when document has two columns, you have two options, hot to insert long table in the document:
    • manually split table into two parts, each parts enclosed in table* float and for numbering of their captions use \ContinuedFloat command from caption package
    • before table change document format from two columns to one and return back two columns after table. At this you should be aware, that commands, which make this changes (\onecolumn and twocolumn) start new page. Consequently at this usual appears empty spaces before and after table (which as far as I know, cannot be removed by use of the afterpage package)

First solution: Based is on my answer on your previous question. For positioning tables at the bottom of the same page where is inserted and on the top of the next page is used stfloats package:

\documentclass[journal]{IEEEtran}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%
\usepackage{newtxtext, newtxmath}
\usepackage[export]{adjustbox}   % it load graphicx too
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{caption}  % <--- new
\usepackage{stfloats} % <--- new

\begin{document}
\lipsum
    \begin{table*}[b]
\caption{Table with images}
  \label{tab:image}
    \adjustboxset{width=\linewidth, valign=M}
\begin{tblr}{hlines, vlines,
             colsep=3pt,
             colspec= {c *{3}{X[c,m]} },
             row{1} = {font=\bfseries},
             rowsep = 3pt,
             }
No  &   C1  &   C3  &   C4  \\
1   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
2   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
3   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
\end{tblr}
    \end{table*}
    \begin{table*}[t]
    \ContinuedFloat
\caption{Table with images}
  \label{tab:image}
    \adjustboxset{width=\linewidth, valign=M}
\begin{tblr}{hlines, vlines,
             colsep=3pt,
             colspec= {c *{3}{X[c,m]} },
             row{1} = {font=\bfseries},
             rowsep = 3pt,
             }
No  &   C1  &   C3  &   C4  \\
4   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
5   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
6   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
7   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
\end{tblr}
    \end{table*}
\lipsum\lipsum
\end{document}

enter image description here

Second solution: Use a long table, where are you need

  • removed table float
  • for table use of longtblr package instead of tblr
  • for changes from one column to one column and back are used commands \onecolumn and \twocolumn respectively
\documentclass[journal]{IEEEtran}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum}                             % for dummy text
%---------------------------------------------------------------%

\usepackage{newtxtext, newtxmath}
\usepackage[export]{adjustbox}   % it load graphicx too
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
\lipsum
\onecolumn
    \adjustboxset{width=\linewidth, valign=M}
\begin{longtblr}[
caption = {Table with images},
  label = {tab:image}
                ]{hlines, vlines,
             colsep=3pt,
             colspec= {c *{3}{X[c,m]} },
             row{1} = {font=\bfseries},
             rowsep = 3pt,
             }
No  &   C1  &   C3  &   C4  \\
1   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
2   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
3   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
4   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
5   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
6   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
7   & \adjincludegraphics{example-image-a}
            & \adjincludegraphics{example-image-b}
                    & \adjincludegraphics{example-image-c}  \\
\end{longtblr}
\twocolumn
\lipsum
\end{document}

enter image description here

Addendum:

  • With your comments your question become unclear, what actually is your problem.
  • As far as I see, original version of answer solve all problems mentioned in your question.
  • Site is not a forum. If you have new problem(s), on which you become aware after use of received answer, please ask new question. (Sub)question asked in comments are not (well) visible to others, which may help you better than me, so y this you exclude them to help you.
  • Regarding your last request given in comments below:
    • vertical lines only in the first row:
\begin{tblr}{hlines, vline{1-Z}={1}{solid}, % <---
             colsep=3pt,
             colspec= {c *{3}{X[c,m]} },
             row{1} = {font=\bfseries},
             rowsep = 3pt,
             }

enter image description here

  • smaller height of images, for example that their heights is only 22mm:
    \adjustboxset{width=\linewidth, height=22mm, valign=M}

enter image description here

  • for other options please consult packages documentations. They are part of your LaTeX installation and are also available on CTAN (use Google).
17
  • I'm sorry that the paper is two column format but I'm going to put the table like combining two columns so would that easy to modify?
    – hana
    Jul 9, 2022 at 16:55
  • @hana, in answer you have two possible solutions, how to do this. Choose one of them which you estimate that is the mots appropriate for you, There is no other possibilities. If no one suggested solution is easy to you, I don't (and can't) know.
    – Zarko
    Jul 9, 2022 at 17:33
  • Thanks, the first one is what I'm looking for.
    – hana
    Jul 9, 2022 at 19:05
  • @hana, than you may consider to accept it ;-)
    – Zarko
    Jul 9, 2022 at 20:10
  • 1
    @hana, yes, this is main difference. Overleaf have outdated installation of tabularray. Ask their help how to install recent version (2022B) to your local l repository or install LaTeX on your computer.
    – Zarko
    Jul 9, 2022 at 21:59

You must log in to answer this question.

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