0

I have a tabularx table (6x2) with figure+text in all of its cells except the head. I've been trying to continue/flow this table over to the next page using packages like ltablex and xltabular, but in vain. Is it due to the fact that figures in tabularx hinder the table continuation over to the next page? Can anyone please show me an implementation of text+figure in all cells of tabularx with continuous flow of the table to the next page, if you can implement using ltablex/xltabular? I'll be grateful.

Here's my original tabularx code -

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage[font=small]{caption}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{booktabs,makecell}
\renewcommand\tabularxcolumn[1]{m{#1}}

\begin{document}

\begin{tabularx}{\textwidth}{@{} >{\centering\arraybackslash}X | >{\centering\arraybackslash}X @{}}


\toprule 
     {\bfseries{Column 1}} & {\bfseries{Column 2}}  \\ 
     \midrule 
     %\endhead


\small \noindent
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 2 Column 1} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage} 

& \small \noindent     
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 2 Column 2} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage}

  \\ \cmidrule(lr){1-2}


\small \noindent
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 3 Column 1} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage} 

& \small \noindent     
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 3 Column 2} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage}

  \\ \cmidrule(lr){1-2}


\small \noindent
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 4 Column 1} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage} 

& \small \noindent     
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 4 Column 2} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage}

  \\ \cmidrule(lr){1-2}


\small \noindent
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 5 Column 1} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage} 

& \small \noindent     
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 5 Column 2} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage}

  \\ \cmidrule(lr){1-2}


\small \noindent
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 6 Column 1} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage} 

& \small \noindent     
\begin{minipage}[t]{\linewidth} %\noalign{\vskip }
\multicolumn{1}{l}{Row 6 Column 2} 
   \begin{enumerate}[leftmargin=*]
   \item Something something something something. \par 
        \begin{minipage}[t]{\linewidth} \noindent
            \centering \noindent
            \includegraphics[width=\linewidth]{Illustrative.png}
            \captionof{figure}{Figure in enumeration in tabularx}
        \end{minipage}
   \item Something something something something.
   \item Something something something something.
   \end{enumerate}
%\noalign{\vskip }
\end{minipage}

  \\ \bottomrule 


%\label{tab:1} 
%    \caption{Something tabularx trying to flow to the next page.}

\end{tabularx}

\end{document}

And here's the output -

enter image description here

11
  • 1
    Welcome to TeX SX! Which document class are you using?
    – Bernard
    Apr 13, 2021 at 13:18
  • @Bernard It's a custom made template that I imported from elsewhere. It's document class seems to be declared as \usepackage[margin=0.8in]{geometry}.
    – Ajax
    Apr 13, 2021 at 13:28
  • No, that's a package for the layout The \documentclass, normally, is the first line of code.
    – Bernard
    Apr 13, 2021 at 13:33
  • @Bernard. I see. Here's what I found then - \documentclass[12pt]{article}
    – Ajax
    Apr 13, 2021 at 13:34
  • 1
    The code doesn't run for me. It gives a lot of errors. And you are right about the \linewidth, sorry about that. I deleted that comment. Apr 13, 2021 at 14:19

1 Answer 1

0

EDIT 1: I found a solution for \captionof, see the code immediately after \begin{document}.

I have cleaned up the code and used ltablex. That seems to work. (xltabular should probably also work, but it is incompatible with booktabs.) EDIT 2: I tried it with a cleaned up code, and it worked with xltabular and booktabs. Just replace \usepackage{ltabularx} with \usepackage{xltabular}, and the tabularx environment with xltabular.

There is only one thing: you cannot use \captionof inside the minipage, as it calls \caption and that is redefined by these packages in such a way that it must be used directly in the tabular, not inside anything else. So you must find a different solution for this.

To make the code simpler I have put the minipage in a macro. In real life you wouldn't do that, but in this way the code is shorter and easier to understand.

\documentclass{article}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage[font=small]{caption}
\usepackage{multirow}
\usepackage{ltablex}
\usepackage{booktabs}
\usepackage[margin=0.8in]{geometry}
\renewcommand\tabularxcolumn[1]{m{#1}}

\newcommand\onecell{
\small \noindent
\begin{minipage}[t]{\linewidth}
    \begin{enumerate}[leftmargin=*]
    \item Something something something something. \par 
         \begin{minipage}[t]{\linewidth} \noindent
             \centering \noindent
             \includegraphics[width=\linewidth]{example-image}
             \captionof{figure}{Figure in enumeration in tabularx}
         \end{minipage}
    \item Something something something something.
    \item Something something something something.
    \end{enumerate}
\end{minipage} 
}

\begin{document}
% This code must be after \begin{document}, not in the preamble
\newcommand\origcaption{}
\newcommand\origcaptionof{}
\let\origcaption\caption
\let\origcaptionof\captionof
\renewcommand{\captionof}{\let\caption\origcaption\origcaptionof}

\begin{tabularx}{\textwidth}{@{} >{\centering\arraybackslash}X | >{\centering\arraybackslash}X @{}}

  \toprule 
     {\bfseries{Column 1}} & {\bfseries{Column 2}}  \\ 
     \midrule 
     \endhead

 \onecell
& 
 \onecell
  \\ \cmidrule(lr){1-2}

 \onecell
&
 \onecell
  \\ \cmidrule(lr){1-2}
 \onecell
&
 \onecell
  \\ \cmidrule(lr){1-2}
 \onecell
&
 \onecell
  \\ \cmidrule(lr){1-2}

 \onecell
&
 \onecell
  \\ \bottomrule 

    \caption{Something tabularx trying to flow to the next page.\label{tab:1}}

\end{tabularx}

\end{document}

enter image description here

4
  • Out of curiosity: How do you come to the conclusion that xltabular is incompatible with booktabs?
    – leandriis
    Apr 13, 2021 at 18:08
  • @leandriis I got errors with xltabular and booktabs together, and there are other posts that describe this. For example tex.stackexchange.com/q/522920/113546 The solution given there, didn't work for me. Apr 13, 2021 at 19:04
  • I tried it again with a cleaned up code, and now it worked with xltabular and booktabs. Apr 14, 2021 at 9:13
  • @PietervanOostrum Thank you! Your solution for \captionof in minipage works like a charm.
    – Ajax
    Apr 14, 2021 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.