我有一张tabularx
表格 (6x2),除了表头外,所有单元格中都有图形+文本。我一直尝试使用 和 之类的包将此表格继续/流动到下一页ltablex
,xltabular
但徒劳无功。是不是因为 中的图形妨碍了表格继续到下一页?如果您可以使用/实现tabularx
,有人可以向我展示 的所有单元格中都有文本+图形的实现,tabularx
并使表格连续流动到下一页吗?我将不胜感激。ltablex
xltabular
这是我的原始tabularx
代码-
\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}
以下是输出 -
答案1
编辑1:我找到了解决方案\captionof
,请立即查看之后的代码\begin{document}
。
我已经清理了代码并使用了ltablex
。这似乎有效。(xltabular
可能也应该有效,但它与booktabs
。)编辑2:我尝试使用清理过的代码,它可以与xltabular
和 一起使用booktabs
。只需用 替换\usepackage{ltabularx}
,\usepackage{xltabular}
并将tabularx
环境替换为xltabular
。
只有一件事:您不能\captionof
在 中使用minipage
,因为它调用了\caption
,并且这些包重新定义了它,以至于它必须直接在表格中使用,而不是在其他任何地方使用。所以你必须为此找到不同的解决方案。
为了简化代码,我将 放在了minipage
宏中。在现实生活中你不会这样做,但这样代码会更短,更容易理解。
\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}