如何将 \multicolumn 中的 \multirow 的宽度设置为整个表格宽度

如何将 \multicolumn 中的 \multirow 的宽度设置为整个表格宽度

我希望表格底部有多行多列的文本。

在此处输入图片描述

我在表格中加入了上标的解释性文字,并解释了所有缩写。

我可以以某种方式强制使用多列并手动将我的文本分成多行,但文本却没有对齐,而这是我想要的。

梅威瑟:

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{multirow}

\begin{document}
\begin{table}[]
\centering
\caption{Caption}}
\label{}
\resizebox{\textwidth}{!}{%
\begin{tabular}{ccccccccccccc}
          &                           &              &  & \multicolumn{9}{c}{A}                                                                                     \\ \cline{5-13} 
          &                           &              &  & \multicolumn{4}{c}{1}                          &  & \multicolumn{4}{c}{2}                            \\ \cline{5-8} \cline{10-13} 
C:DBE     & \textit{m/z} [M + Na]$^+$ & Compound$^e$ &  & Peaks & Isomers &      & Most abundant FA pair$^a$ &  & Peaks & Isomers &      & Most abundant FA pair$^a$   \\ \cline{1-3} \cline{5-8} \cline{10-13} 
C:DBE        & value                 &              &  &       &         &      &                           &  & 1     & 2       &      & thing/                   \\
\multicolumn{13}{l}{\multirow{}{\dimexpr\textwidth-2\tabcolsep\relax}{$^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns}}  

\end{tabular}%
}
\end{table}

\end{document}

我想要很长的文本跨越整个表格的宽度。我尝试将宽度设置为 \textwidth,但最终结果与此完全相似。

抱歉,如果图像出现在文本中间,我不知道如何移动它。

答案1

您不需要\multicolumn\multirow在这里也不需要将表格缩放到任意不一致的字体大小。

在此处输入图片描述

只需选择较小的字体大小(\scriptsize此处)并将注释移到表格后面。

\documentclass[12pt]{article}

\newcommand\hd[1]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}

\begin{document}
\begin{table}[htp]

\caption{Caption\label{zz}}

\scriptsize
\setlength\tabcolsep{1.9pt}
\begin{tabular}{@{}ccccccccccccc@{}}
          &                           &              &  & \multicolumn{9}{c@{}}{A}                                                                                     \\ \cline{5-13} 
          &                           &              &  & \multicolumn{4}{c}{1}                          &  & \multicolumn{4}{c@{}}{2}                            \\ \cline{5-8} \cline{10-13} 
C:DBE     & \textit{m/z} [M + Na]$^+$ & Compound$^e$ &  & Peaks & Isomers &      & \hd{Most abundant\\ FA pair$^a$} &  & Peaks & Isomers &      & \hd{Most abundant\\ FA pair$^a$}   \\
\cline{1-3} \cline{5-8} \cline{10-13} 
C:DBE        & value                 &              &  &       &         &      &                           &  & 1     & 2       &      & thing/                   \\
\end{tabular}

$^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns 



\end{table}

\end{document}

答案2

这是尝试将 David 已经说过的内容放入 MWE 中。我使用了adjustbox而不是\resizeboxragged2e\justify

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage{ragged2e}

\begin{document}
\begin{table}[]
    \centering
    \caption{Caption}
    \label{}
    \adjustbox{width=\textwidth}{
        \begin{tabular}{*{13}{c}}
                  &                           &              & & \multicolumn{9}{c}{A}                                                                                     \\ \cline{5-13}
                  &                           &              & & \multicolumn{4}{c}{1}                                                                                                     &         & \multicolumn{4}{c}{2}                            \\ \cline{5-8} \cline{10-13}
            C:DBE & \textit{m/z} [M + Na]$^+$ & Compound$^e$ & & Peaks                                                                                                                     & Isomers &                                                                               & Most abundant FA pair$^a$ & & Peaks & Isomers & & Most abundant FA pair$^a$   \\ \cline{1-3} \cline{5-8} \cline{10-13}
            C:DBE & value                     &              & &                                                                                                                           &         &                                                                               &                           & & 1     & 2       & & thing/                   \\
        \end{tabular}%
    }
    \justify{\scriptsize
        a very long text that spans 4-5 lines and all columns a very long text that spans 4-5 lines and all columns a very long text that spans 4-5 lines and all columns a very long text that spans 4-5 lines and all columns a very long text that spans 4-5 lines and all columns a very long text that spans 4-5 lines and all columns a very long text that spans 4-5 lines and all columns a very long text that spans 4-5 lines and all columns a very long text that spans 4-5 lines and all columns a very long text that spans 4-5 lines and all columns
    }
\end{table}

\end{document}

在此处输入图片描述

答案3

我认为您可能想要的是 的功能threeparttable除此之外,几乎不可能有 13 列适合 A4 纸的文本宽度,即使使用字体大小和 的值也是如此\tabcolsep。所以我建议使用sidewaystable。我添加了一些美学改进,例如使用 的规则booktabs和 的两行列标题makecell

\documentclass[12pt]{article}
\usepackage{graphicx, rotating}
\usepackage{threeparttable}
\usepackage{makecell}
\usepackage{booktabs}

\begin{document}

\begin{sidewaystable}%[!htb]
\centering\small \setlength{\tabcolsep}{3pt}
\setlength{\cmidrulekern}{0.25em}
\begin{threeparttable}
\caption{Caption}
\label{}
\begin{tabular}{*{13}{c}}
          & & & & \multicolumn{9}{c}{A} \\ \cmidrule[\heavyrulewidth]{5-13}
          & & & & \multicolumn{4}{c}{1} & & \multicolumn{4}{c}{2} \\ \cmidrule(lr){5-8} \cmidrule(lr){10-13}
C:DBE & \textit{m/z} [M + Na]$^+$ & Compound\tnote{e} & & Peaks & Isomers & & \thead{Most abundant\\ FA pair\tnote{a}} & & Peaks & Isomers & & \thead{Most abundant\\ FA pair\tnote{a}} \\ \cmidrule(lr){1-3} \cmidrule(lr){5-8} \cmidrule(lr){10-13}
C:DBE & value & & & & & & & & 1 & 2 & & thing/ \\
\bottomrule
\end{tabular}%
\begin{tablenotes}[flushleft]\footnotesize\smallskip
\item[a] very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns
    \item[e]very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns $^a$ very long text that spans 4-5 lines and all columns
\end{tablenotes}
\end{threeparttable}
\end{sidewaystable}

\end{document} 

在此处输入图片描述

相关内容