表格标题处有新行

表格标题处有新行
\documentclass{article}    
\usepackage{adjustbox}

\usepackage{lipsum}% example text

\begin{document}

\lipsum

\begin{table}[ht]
\centering
\begin{adjustbox}{width=1\textwidth}
\small
\begin{tabular}{rlrrrrrrr}
  \hline
 & X & line break & MASHvsBEEML & tRapvsBEEML & frequency & Mash\_mean & BEEML\_mean & tRap\_mean \\ 
  \hline
1 & ETS & 8.95e-04 & 7.35e-04 & 4.78e-06 &  10 & 0.52 & 0.67 & 0.30 \\ 
  11 & ZnF\_C2H2 & 7.08e-21 & 2.09e-02 & 1.70e-26 &  54 & 0.55 & 0.64 & 0.25 \\ 
  10 & Zn2Cys6 & 4.94e-04 & 5.50e-02 & 3.52e-06 &  17 & 0.38 & 0.61 & 0.13 \\ 
  8 & IRF & 1.16e-06 & 6.65e-02 & 5.54e-08 &  10 & 0.52 & 0.62 & 0.28 \\ 
  2 & FH & 1.27e-05 & 8.61e-02 & 5.20e-07 &  10 & 0.53 & 0.66 & 0.27 \\ 
  3 & HLH & 2.49e-05 & 1.31e+00 & 4.27e-05 &  13 & 0.61 & 0.74 & 0.26 \\ 
  4 & HMG & 8.73e-33 & 1.41e+00 & 3.49e-08 &  44 & 0.55 & 0.48 & 0.12 \\ 
  12 & ZnF\_C4 & 2.92e-06 & 1.92e+00 & 1.03e-07 &  10 & 0.66 & 0.73 & 0.27 \\ 
  9 & unknown & 3.15e-27 & 1.96e+00 & 5.38e-21 & 121 & 0.44 & 0.49 & 0.16 \\ 
  5 & Homeo & 1.69e-164 & 6.26e+00 & 2.35e-75 & 158 & 0.72 & 0.73 & 0.17 \\ 
  7 & Homeo, POU & 3.12e-12 & 7.36e+00 & 5.21e-12 &  11 & 0.69 & 0.70 & 0.18 \\ 
  6 & Homeo  & 9.82e-13 & 9.73e+00 & 1.21e-05 &  19 & 0.67 & 0.65 & 0.14 \\ 
   \hline
\end{tabular}
\end{adjustbox}
\caption{Paired t-test of most common TF families for Pearson Correlations} 
\end{table} 

\lipsum

\end{document}

我想在两行中写“换行符”。我尝试过这样做, \\但结果却出现了另一行, \newline代码不起作用。我想编辑我的表格,使其像第二行一样。 抱歉我的绘画技巧不好 :(

答案1

一种可能性是:

在此处输入图片描述

\documentclass{article}
\usepackage{adjustbox}
\usepackage{booktabs, makecell}

\usepackage{lipsum}% example text

\begin{document}
\lipsum[11]
    \begin{table}[ht]
\centering
\small
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}rl rr rr rr r}
  \toprule
    &   \thead[b]{X}
        &   \thead[b]{line\\ break}
            &   \thead[b]{MASH vs\\ BEEML}
                &   \thead[b]{tRap vs\\ BEEML}
                    &   \thead[b]{freq.}
                        &   \thead{Mash\\ mean}
                            &   \thead[b]{BEEML\\ mean}
                                &   \thead[b]{tRap\\ mean} \\
  \midrule
1   & ETS & 8.95e-04 & 7.35e-04 & 4.78e-06 &  10 & 0.52 & 0.67 & 0.30 \\
11  & ZnF\_C2H2 & 7.08e-21 & 2.09e-02 & 1.70e-26 &  54 & 0.55 & 0.64 & 0.25 \\
10 & Zn2Cys6 & 4.94e-04 & 5.50e-02 & 3.52e-06 &  17 & 0.38 & 0.61 & 0.13 \\
8 & IRF & 1.16e-06 & 6.65e-02 & 5.54e-08 &  10 & 0.52 & 0.62 & 0.28 \\
2 & FH & 1.27e-05 & 8.61e-02 & 5.20e-07 &  10 & 0.53 & 0.66 & 0.27 \\
3 & HLH & 2.49e-05 & 1.31e+00 & 4.27e-05 &  13 & 0.61 & 0.74 & 0.26 \\
4 & HMG & 8.73e-33 & 1.41e+00 & 3.49e-08 &  44 & 0.55 & 0.48 & 0.12 \\
12 & ZnF\_C4 & 2.92e-06 & 1.92e+00 & 1.03e-07 &  10 & 0.66 & 0.73 & 0.27 \\
9 & unknown & 3.15e-27 & 1.96e+00 & 5.38e-21 & 121 & 0.44 & 0.49 & 0.16 \\
5 & Homeo & 1.69e-164 & 6.26e+00 & 2.35e-75 & 158 & 0.72 & 0.73 & 0.17 \\
7 & Homeo, POU & 3.12e-12 & 7.36e+00 & 5.21e-12 &  11 & 0.69 & 0.70 & 0.18 \\
6 & Homeo  & 9.82e-13 & 9.73e+00 & 1.21e-05 &  19 & 0.67 & 0.65 & 0.14 \\
   \bottomrule
\end{tabular*}
\caption{Paired t-test of most common TF families for Pearson Correlations}
    \end{table}
\lipsum
\end{document}

补充: 使用S来自包“siunitx”的列类型的示例:

在此处输入图片描述

其结果是:

\documentclass{article}
\usepackage{adjustbox}
\usepackage{booktabs, makecell}
\usepackage{siunitx}

\usepackage{lipsum}% example text

\begin{document}
\lipsum[11]
    \begin{table}[ht]
\centering
\small
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}rl 
                           *{3}{S[table-format=1.2,
                                  table-figures-exponent=5,
                                  exponent-product={\cdot}]}
                                S[table-format=3.0]
                           *{3}{S[table-format=1.2]}
                                }
  \toprule
    &   \thead[b]{X}
        &   {\thead[b]{line\\ break}}
            &   {\thead[b]{MASH vs\\ BEEML}}
                &   {\thead[b]{tRap vs\\ BEEML}}
                    &   {\thead[b]{freq.}}
                        &   {\thead[b]{Mash\\ mean}}
                            &   {\thead[b]{BEEML\\ mean}}
                                &   {\thead[b]{tRap\\ mean}} \\
  \midrule
1   & ETS       & 8.95e-04  & 7.35e-04 & 4.78e-06 &  10 & 0.52 & 0.67 & 0.30 \\
11  & ZnF\_C2H2 & 7.08e-21  & 2.09e-02 & 1.70e-26 &  54 & 0.55 & 0.64 & 0.25 \\
10  & Zn2Cys6   & 4.94e-04  & 5.50e-02 & 3.52e-06 &  17 & 0.38 & 0.61 & 0.13 \\
8   & IRF       & 1.16e-06  & 6.65e-02 & 5.54e-08 &  10 & 0.52 & 0.62 & 0.28 \\
2   & FH        & 1.27e-05  & 8.61e-02 & 5.20e-07 &  10 & 0.53 & 0.66 & 0.27 \\
3   & HLH       & 2.49e-05  & 1.31e+00 & 4.27e-05 &  13 & 0.61 & 0.74 & 0.26 \\
4   & HMG       & 8.73e-33  & 1.41e+00 & 3.49e-08 &  44 & 0.55 & 0.48 & 0.12 \\
12  & ZnF\_C4   & 2.92e-06  & 1.92e+00 & 1.03e-07 &  10 & 0.66 & 0.73 & 0.27 \\
9   & unknown   & 3.15e-27  & 1.96e+00 & 5.38e-21 & 121 & 0.44 & 0.49 & 0.16 \\
5   & Homeo     & 1.69e-164 & 6.26e+00 & 2.35e-75 & 158 & 0.72 & 0.73 & 0.17 \\
7   & Homeo, POU & 3.12e-12 & 7.36e+00 & 5.21e-12 &  11 & 0.69 & 0.70 & 0.18 \\
6   & Homeo     & 9.82e-13  & 9.73e+00 & 1.21e-05 &  19 & 0.67 & 0.65 & 0.14 \\
   \bottomrule
\end{tabular*}
\caption{Paired t-test of most common TF families for Pearson Correlations}
    \end{table}
\lipsum
\end{document}

相关内容