幫忙修桌子

幫忙修桌子

我嘗試使用一個適用於更多數位表格的模板,但我創建了一個怪物試圖使其適應新的需求。這是 mwe:

\documentclass[a4paper, 11pt]{scrreprt}
\usepackage{amsmath,booktabs,siunitx}
\usepackage[version=4]{mhchem}  
\sisetup{separate-uncertainty}

\newcommand{\tabhead}[1]{%
    \smash[b]{%
        \begin{tabular}[t]{@{}c@{}}#1\end{tabular}%
    }%
}

\begin{document}

\begin{table}[h]

    \caption{Caption here.}\label{whatever}

    \setlength{\tabcolsep}{0pt}

    \begin{tabular*}{\linewidth}{
            @{\extracolsep{\fill}}
            r
            S[table-format=2.1]
            r
            S[table-format=1.2]
            r
            S[table-format=4.0]
            r
            r
        }
        \toprule
        {\textbf{Material} } &
        {\tabhead{ \textbf{Mean Pore Radius} \\ \textbf{(\si{\nano\meter})}}} &
        { \textbf{Model}} &
        {\tabhead{\textbf{Salt Concentration} \\ \textbf{({M} \ce{NaCl})}}} &
        {\textbf{pH}} &
        {\textbf{Buffer}} &
        {\tabhead{Range of Dextrans \\ \textbf{(kDa)}}} &
        {\tabhead{Reference \\ \textbf{(--)}}} \\
        &&&  \\
        \midrule
        LongName AA         &   18.4 & Simple model   &   0   & 20 mM Bis-Tris          &   6.5     &   0.18 to 500      &  [1,2]   \\ 
        LongName AA         &   25.8 & complex model  & 0.12  &  10 mM Tris-\ce{HCl}    &   7.2     & 0.18 to 20000      &  [3] \\  
        AA LongName  AA     &   15.0 & complex model  & 1     &  10 mM phosphate        &   8.0     &  4 to 400          &  [4,2]\\ 

        \bottomrule
    \end{tabular*}
    \label{}

\end{table}

\end{document}

它編譯時沒有錯誤,但一方面它不適合頁面,所以我看不到整個表格,而且還有其他許多錯誤的事情,例如:

  • 標題重疊。標題之間沒有適當的距離。
  • 如何將元素右對齊但使標題居中排列?
  • 在這種情況下我應該使用 tabularx 嗎?

任何幫助表示讚賞!

答案1

使這些長標題適應頁面限制的希望不大。我建議使用表格下方(或可能在標題中)解釋的首字母縮寫。

\documentclass[a4paper, 11pt]{scrreprt}
\usepackage{amsmath,booktabs,siunitx}
\usepackage[version=4]{mhchem}  
\sisetup{separate-uncertainty}

\begin{document}

\begin{table}[htp]

\caption{Caption here.}\label{whatever}

\setlength{\tabcolsep}{0pt}

\footnotesize

\begin{tabular*}{\linewidth}{
  @{\extracolsep{\fill}}
  l
  S[table-format=2.1]
  l
  S[table-format=1.2]
  l
  S[table-format=1.1]
  l
  r
}
\toprule
\textbf{Material} & {\textbf{MPR}} & \multicolumn{1}{c}{\textbf{Model}} & {\textbf{SC}} &
\multicolumn{1}{c}{\textbf{pH}} & {\textbf{B}} & \textbf{RD} & \textbf{Ref.} \\
\midrule
LongName AA    & 18.4 & Simple model  & 0    & 20 mM Bis-Tris      & 6.5 & 0.18 to 500   &  [1,2] \\ 
LongName AA    & 25.8 & complex model & 0.12 & 10 mM Tris-\ce{HCl} & 7.2 & 0.18 to 20000 &  [3] \\  
AA LongName AA & 15.0 & complex model & 1    & 10 mM phosphate     & 8.0 & 4 to 400      &  [4,2] \\ 
\midrule[\heavyrulewidth]
\end{tabular*}
\begin{tabular*}{\textwidth}[t]{@{\extracolsep{\fill}}lll}
MPR: Mean Pore Radius (\si{\nano\meter}) &
SC: Salt Concentration (M \ce{NaCl}) &
B: Buffer \\
RD: Range of Dextrans (kDa) & Ref.: Reference
\end{tabular*}

\end{table}

\end{document}

如果沒有\footnotesize柱子就會太擠壓。根據您的文字寬度,\small可以。

在此輸入影像描述

相關內容