首页 > 解决方案 > 如何在突出显示的列中对齐 CENTER(水平顶部)的内容?

问题描述

我是乳胶新手,并且卡在表格的格式和对齐方式中。我还附上了截图。

截屏

代码:

\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}

标签: latex

解决方案


您可以使用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}

在此处输入图像描述


推荐阅读