如何在突出显示的列中对齐CENTER(水平顶部)内容?

时间:2019-03-28 16:32:27

标签: latex

我是乳胶的新手,对表格的格式和对齐方式一无所知。我还附上了截图。

Screenshot

代码:

\begin{landscape}
\begingroup
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%\renewcommand{\arraystretch}{0.8}
\begin{table}
\footnotesize
\linespread{1.2}  %   this decrease the vertical spacing between lines
\rmfamily        %   without this, \linespread doesn't give expected effect
\caption{Datasets used in our study, (1 Gbyte = 10\textsuperscript{9} bytes)}

    \begin{tabular}{ p{0.7em}  p{7.5em} p{2.3em}  p{2em} p{2em}  p{18em} | p{2em}  p{2em} p{2em}  p{18em} } \hline
        \multirow{2}{*}{SN} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Tools (version; \\ compression type)\end{tabular}} & \multicolumn{4}{c}{\textit{k = 28}} & \multicolumn{4}{c}{\textit{k = 55}} \\ \cline{3-6} \cline{7-10}
        &  & \begin{tabular}[c]{@{}c@{}} Time\\ (s)\end{tabular} & \begin{tabular}[c]{@{}c@{}}RAM\\ (GB)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Disk\\ (GB)\end{tabular} & \begin{tabular}[c]{@{}l@{}}CPU utilization (\%) \\ (comment)\end{tabular}  & \begin{tabular}[c]{@{}c@{}} Time\\ (s)\end{tabular} & \begin{tabular}[c]{@{}c@{}}RAM\\ (GB)\end{tabular} & \begin{tabular}[c]{@{}c@{}}Disk\\ (GB)\end{tabular} & \begin{tabular}[c]{@{}l@{}}CPU utilization (\%) \\ (comment)\end{tabular}\\ \hline

    1 & Jellyfish (2.2.6) & 138.33 & 7.9 & 0 & 1093.55 (consistent) & 226 & \textit{\textbf{36.19}} & 0 & \textbf{1050.93* (consistent)} \\ 
    2 & DSK (2.2.0) & 56.33 & 6.35 & 6 & 866.50 (consistent) & 78.33 & 7.04 & 5 & 633.49 (declined from $\sim$1174 to $\sim$129.7) \\ 
    3 & DSK (2.2.0; gzip) & 194 & 4 & 6 & 402.71(first 80\% of time consistent  with $\sim$300; last 20\% inconsistent to $\sim$1200 with sudden increase) & 222 & 6 & 5 & 441.21 (first 75\% of time consistent with $\sim$390; last 25\% inconsistent to $\sim$1200 with sudden increase) \\ 

\end{tabular}
\end{table}
\endgroup
\end{landscape}

1 个答案:

答案 0 :(得分:0)

您可以使用siunitx软件包。它定义了一个新的列类型S,它使数字在小数点处对齐。

该包完全被您过于复杂的表所干扰,其中包含许多嵌套表。通常,您永远不需要这样做。我用一种更简单,更易读的方式重写了您的表。

请注意,S列需要具有数字输入。如果您有一些文字(例如标题中的文字),可以

  • 将单元格的类型定义为c(或l,p等)\multicolumn{1}{c}{text entry}
  • 或仅将您的条目括在大括号{text entry}
\documentclass{article}
\usepackage{lscape}
\usepackage{array}
\usepackage{multirow}
\usepackage{siunitx}

\begin{document}

\begin{landscape}
\begingroup
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%\renewcommand{\arraystretch}{0.8}
\begin{table}
\footnotesize
\linespread{1.2}  %   this decrease the vertical spacing between lines
\rmfamily        %   without this, \linespread doesn't give expected effect
\caption{Datasets used in our study, (1 Gbyte = 10\textsuperscript{9} bytes)}


\begin{tabular}{ p{0.7em}  p{7.5em} SSS  p{18em} | SSS  p{18em} }
      \hline
      \multirow{2}{*}{SN} &Tools (version; &\multicolumn{4}{c}{\textit{k = 28}} & \multicolumn{4}{c}{\textit{k = 55}} \\
      \cline{3-6} \cline{7-10}
                          &compression&{Time}& {RAM}& {Disk}&{CPU utilization (\%)}&{Time}& {RAM}&{Disk}&{CPU utilization (\%)}\\
                          & type)     &{(s)} &{(GB)}&{(GB)} &{(comment)}           &{(s)} &{(GB)}&{(GB)}&{(comment)}\\
      \hline
    1 & Jellyfish (2.2.6) & 138.33 & 7.9 & 0 & 1093.55 (consistent) & 226 & \textit{\textbf{36.19}} & 0 & \textbf{1050.93* (consistent)} \\ 
    2 & DSK (2.2.0) & 56.33 & 6.35 & 6 & 866.50 (consistent) & 78.33 & 7.04 & 5 & 633.49 (declined from $\sim$1174 to $\sim$129.7) \\ 
    3 & DSK (2.2.0; gzip) & 194 & 4 & 6 & 402.71(first 80\% of time consistent  with $\sim$300; last 20\% inconsistent to $\sim$1200 with sudden increase) & 222 & 6 & 5 & 441.21 (first 75\% of time consistent with $\sim$390; last 25\% inconsistent to $\sim$1200 with sudden increase) \\ 

\end{tabular}
\end{table}
\endgroup
\end{landscape}
\end{document}

enter image description here