垂直表格对齐——噩梦

垂直表格对齐——噩梦

各位,我已经查看了关于这个主题的多个问题,但我找不到直接的答案!我有下表:

在此处输入图片描述

而且,正如您所见,存在多个问题!我在第一个框中看到“ --- ”,我不知道为什么……然后,任何单元格数组都对齐了!因此数字是不可察觉的……

这是代码,请帮帮我。

\begin{center}
\renewcommand{\arraystretch}{1.25}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}b{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}b{#1}}

\begin{table*}[!t]
    \centering
    \caption{Information regarding the MOIs}\label{tab:L2}
  \begin{tabular}{R{1.3cm}*{1}{C{.8cm}}|*{2}{C{1cm}}|*{2}{C{1cm}}|*{2}{C{1cm}}|*{4}{C{1.3cm}}}|
    &  &\multicolumn{2}{c|}{\textbf{Velocity(ms$^{-1}$)}} & \multicolumn{2}{c|}{\textbf{Acceleration(ms$^{-2}$)}} & \multicolumn{2}{c|}{\textbf{Jerk(ms$^{-3}$)}} \\ 
 \textbf{Sz Type} & \textbf{\#MOIs} & \textbf{Median} & \textbf{Std} & \textbf{Mean} & \textbf{Std} & \textbf{Mean} & \textbf{Std} & \textbf{MD (m)} & \textbf{CD (m)} &  \textbf{MOI duration (s)} \\ \hline
      %\midrule
        %\midline
        TLE & 19 & 0.086 $\pm$ 0.064 & 0.58 $\pm$ 0.41 & 12 $\pm$ 8.4 & 38 $\pm$ 33 & 345 $\pm$ 287 & 1,204 $\pm$ 1,151 & 0.15 $\pm$ 0.11 & 6.3 $\pm$ 4.2 & 23 $\pm$ 6.6     \\
 ex-TLE & 23 & 0.068 $\pm$ 0.063 & 0.46 $\pm$ 0.29 & 8.6 $\pm$ 4.6 & 23 $\pm$ 17& 172 $\pm$ 127 & 574 $\pm$ 506       & 0.44 $\pm$ 0.29 & 7.6 $\pm$ 2.9 & 35 $\pm$ 10     \\ \hline
      %\bottomrule
        P & n.a. & n.s & n.s & n.s & n.s & \textless  0.04 & n.s & \textless  0.001 & n.s & \textless  0.01     \\ \hline
        %Note. Values are given as mean $\pm$ SD. n.a., not applicable. n.s., not significant \\ \hline
    \end{tabular}
\end{table*}
\end{center}

另外,我想在表格末尾添加这一行,

%Note. Values are given as mean $\pm$ SD. n.a., not applicable. n.s., not significant

但我不能这样做。谢谢

答案1

这是另一种解决方案,使用siunitx, booktabs, makecellthreeparttable。如果将字体大小设置为 ,则使用较小的边距(1.8 厘米)表格可以适合边距\small。希望将噩梦变成美好的梦想……

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[margin=1.8cm]{geometry}
\usepackage{array, caption, booktabs, threeparttable}
\usepackage{siunitx}

\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadalign{bc}

\begin{document}

\begin{table*}[!t]%
  \sisetup{table-number-alignment = center, separate-uncertainty,table-align-uncertainty = true, detect-weight, zero-decimal-to-integer}
  \renewcommand{\arraystretch}{1.25}\small\setlength\tabcolsep{3pt}
  \centering
  \begin{threeparttable}
    \caption{Information regarding the MOIs}\label{tab:L1}
    \begin{tabular}{@{}rc%
        S[table-format = 1.3(3)]
        S[table-format=1.2(2)]
        S[table-format = 2.1(1)]
        S[table-format=2(2)]
        S[table-format=3(3)]
        S[table-format=4(4)]
        S[table-format=1.2(2)]
        S[table-format=1.1(2)]
        S[table-format=2(2)]@{}}
        \toprule
        & & \multicolumn{2}{c}{\thead{Velocity\\ (\si{\m\per\s})}} &\multicolumn{2}{c}{\thead{Acceleration\\ (\si{\m\per\s\squared})}} &
        \multicolumn{2}{c}{\thead{Jerk\\ (\si{\m\per\s\cubed})}} \\[-6ex]
        \thead{Sz Type} & \thead{\#MOIs} & {\thead{Median}} & {\thead{Std}} & {\thead{Mean}} & {\thead{Std}} & {\thead{Mean}} & {\thead{Std}} & {\thead{MD (m)}} & {\thead{CD (m)}} & {\thead{MOI \\ duration \\(s)}} \\
        \midrule
        TLE & 19 & 0.086 (64) & 0.58 (41) & 12 (84) & 38 (33) & 345 (287) & 1204 (1151) & 0.15 (11) & 6.3 (42) & 23. (66) \\
        \addlinespace
        ex-TLE & 23 & 0.068 (63) & 0.46 (29) & 8.6 (46) & 23 (17) & 172 (127) &574 (506) & 0.44 (29) & 7.6 (29) & 35 (10) \\
        \midrule
        P & n.a. & {n.s.} & {n.s.} & {n.s.} & {n.s.} & {< 0.04} & {n.s.} & {< 0.001} & {n.s.} & {< 0.01} \\
        \bottomrule
      \end{tabular}
      \begin{tablenotes}[online]\medskip\footnotesize
        \item[\em Note. ]Values are given as mean $\pm$ SD. n.a.: not applicable. n.s.: not significant
      \end{tablenotes}
    \end{threeparttable}
  \end{table*}

\end{document} 

在此处输入图片描述

答案2

似乎真的有太多数据无法放入一个横向表格中,我使用了小字体并窃取了一些边距,但实际上它需要一些主题知识的不同布局来压缩数据(例如减少某些字段的小数位数)

在此处输入图片描述

\documentclass[a4paper]{article}
\usepackage{dcolumn,booktabs}
\newcolumntype{d}[1]{D..{#1}}
\begin{document}
\renewcommand{\arraystretch}{1.25}

\begin{table*}[!t]
    \centering
\footnotesize
\setlength\tabcolsep{3pt}
    \caption{Information regarding the MOIs}\label{tab:L2}

\hspace*{-3cm}\begin{tabular}{
lr
d{1.3}@{${}\pm{}$}d{1.3} d{1.2}@{${}\pm{}$}d{1.2} 
d{2.1}@{${}\pm{}$}d{1.1} d{2.0}@{${}\pm{}$}d{2.0} 
d{3.0}@{${}\pm{}$}d{3.0} d{3.0}@{${}\pm{}$}d{5.0} 
d{1.2}@{${}\pm{}$}d{1.2} d{1.1}@{${}\pm{}$}d{1.1} d{2.0}@{${}\pm{}$}d{2.1} 
cccccccccccccccccccccccccccccccccccccccc
}
\toprule

    &  &
\multicolumn{4}{c}{\textbf{Velocity(ms$^{-1}$)}} &
\multicolumn{4}{c}{\textbf{Acceleration(ms$^{-2}$)}} & 
\multicolumn{4}{c}{\textbf{Jerk(ms$^{-3}$)}} \\ 
\multicolumn{1}{c}{\textbf{Type}} &
\multicolumn{1}{c}{\textbf{\#}} & 
\multicolumn{2}{c}{\textbf{Median}} &
\multicolumn{2}{c}{\textbf{Std}} &
\multicolumn{2}{c}{\textbf{Mean}} &
\multicolumn{2}{c}{\textbf{Std}} &
\multicolumn{2}{c}{\textbf{Mean}} &
\multicolumn{2}{c}{\textbf{Std}} &
\multicolumn{2}{c}{\textbf{MD (m)}} &
\multicolumn{2}{c}{\textbf{CD (m)}} &
\multicolumn{2}{c}{\textbf{(s)}} \\ 
      \midrule
              TLE & 19 & 0.086 & 0.064 & 0.58 & 0.41 & 12 & 8.4 & 38 & 33 & 345 & 287 & 1,204 & 1,151 & 0.15 & 0.11 & 6.3 & 4.2 & 23 & 6.6     \\
 ex-TLE & 23 & 0.068 & 0.063 & 0.46 & 0.29 & 8.6 & 4.6 & 23 & 17& 172 & 127 & 574 & 506       & 0.44 & 0.29 & 7.6 & 2.9 & 35 & 10     \\
      \midrule
\multicolumn{1}{c}{P} &
\multicolumn{1}{c}{n.a.}&
\multicolumn{2}{c}{n.s}& 
\multicolumn{2}{c}{n.s}&
\multicolumn{2}{c}{n.s}&
\multicolumn{2}{c}{n.s}&
\multicolumn{2}{c}{${}<  0.04$} &
\multicolumn{2}{c}{n.s}&
\multicolumn{2}{c}{${}<  0.001$} &
\multicolumn{2}{c}{n.s} &
\multicolumn{2}{c}{${}<  0.01$}   \\
      \bottomrule
    \end{tabular}\hspace*{-3cm}

\smallskip

        Note. Values are given as mean $\pm$ SD. n.a., not applicable. n.s., not significant 
\end{table*}


\end{document}

相关内容