latex - 如何在突出显示的列中对齐 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}
解决方案
您可以使用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}
推荐阅读
- python - 需要帮助编写检测文件是否存在的代码
- android - Android Emulator 快照标志不起作用
- python - 使用 python 添加表时出现 sqlite3 错误,但使用 SQLite 的 DB Browser 时没有
- javascript - 为什么每个状态钩子更新都会导致异步代码中的单独重新渲染?
- javascript - 无法从 useEditController 获取数据
- reactjs - React - 尝试添加功能错误 = TypeError: state.notes.map is not a function
- mysql - MySQL从两个字段查询三种状态的逻辑
- html - 如何修复标题滚动和下拉列表消失?
- c++ - CLion 如何为 .clion.resources 指定远程目录
- javascript - 是否有与 JavaScript 中的模板文字等效的 Python?