代码之家  ›  专栏  ›  技术社区  ›  Tjcool

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

  •  0
  • Tjcool  · 技术社区  · 6 年前

    我对乳胶漆还不熟悉,一直坚持着表格的格式和对齐方式。我还附加了一个屏幕截图。

    <>代码:

    \begin landscape
    开始群
    \新列类型P[1]>\居中\阵列反斜杠P 1
    %\ renewcommand \arraystretch 0.8
    开始{{表}
    脚注
    \线间距1.2%这会减小线之间的垂直间距
    \ RmFamily%没有这个,传播不会产生预期的效果。
    \ caption我们研究中使用的数据集(1 gbyte=10\textsuperscript 9 bytes)
    
    \开始表格P 0.7em P 7.5em P 2.3em P 2em P 18em P 2em P 2em 2em P 18em H行
    \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 table&\ begin table[c]@disk \(gb)end table&\ begin[c]@l@cpu utilization(table
    
    1&水母(2.2.6)&138.33&7.9&0&1093.55(一致)&226&\textit \textbf 36.19&0&textbf 1050.93*(一致)\\
    2&dsk(2.2.0)&56.33&6.35&6&866.50(一致)&78.33&7.04&5&633.49(从$1174减少到$129.7)\\
    3&dsk(2.2.0;gzip)&194&4&6&402.71(前80%的时间与\sim$300;后20%的时间与\sim$1200突然增加的时间不一致)&222&6&5&441.21(前75%的时间与\sim$390;后25%的时间与\sim$1200突然增加的时间不一致)\\
    
    \{{表}}
    \{{表}}
    端群
    \{景观}
    < /代码> <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}
    
    0 回复  |  直到 6 年前
        1
  •  0
  •   Alain Merigot    6 年前

    您可以使用 siunitx package.它定义了一个新的列类型S,它将数字与小数点对齐。

    这个包完全被过于复杂的表所干扰,其中包含许多嵌套表。一般来说,你不应该这样做。我以更简单易读的方式重写了您的表。

    请注意,S列需要有一个数字项。如果您有一些文本(例如在标题中),则可以

    • 将单元格的类型重新定义为c(或l,p,etc) \multicoumn 1 c text entry code>。
    • 或者简单地用大括号文本条目将条目括起来
    \documentClass文章
    \使用包装景观
    \使用包数组
    \使用包多行
    \使用包siunitx
    
    \开始文档
    
    \开始景观
    开始群
    \新列类型P[1]>\居中\阵列反斜杠P 1
    %\ renewcommand \arraystretch 0.8
    开始{{表}
    脚注
    \ linespread 1.2%这会减小线之间的垂直间距
    \没有这个的rmfamily%,\linespread不会产生预期的效果
    \ caption我们研究中使用的数据集(1 gbyte=10\textsuperscript 9 bytes)
    
    
    \开始表格P 0.7em P 7.5em SSS P 18em SSS P 18em
    h线
    \多行2 k=55 \\
    \临床3-6 \临床7-10
    &压缩&时间&RAM&磁盘&CPU利用率(\%)&时间&RAM&磁盘&CPU利用率()\\
    &type)&(s)&(gb)&(gb)&(comment)&(s)&(gb)&(gb)&(comment)\\
    h线
    1&水母(2.2.6)&138.33&7.9&0&1093.55(一致)&226&\textit \textbf 36.19&0&textbf 1050.93*(一致)\\
    2&dsk(2.2.0)&56.33&6.35&6&866.50(一致)&78.33&7.04&5&633.49(从$1174减少到$129.7)\\
    3&dsk(2.2.0;gzip)&194&4&6&402.71(前80%的时间与\sim$300;后20%的时间与\sim$1200的时间不一致,但突然增加)&222&6&5&441.21(前75%的时间与\sim$390;后25%的时间与\sim$1200的时间不一致,但突然增加)\\
    
    \{{表}}
    \{{表}}
    端群
    \{景观}
    \Enter {文档}
    < /代码> 
    
    

    小数点上的数字。

    这个包完全被过于复杂的表所干扰,其中包含许多嵌套表。一般来说,你不应该这样做。我以一种更简单易读的方式重写了您的表。

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

    • 将单元格类型重新定义为C(或L、P等)\multicolumn{1}{c}{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