Как я могу выровнять CENTER (горизонтальный верх) содержимого в выделенных столбцах? - PullRequest
0 голосов
/ 28 марта 2019

Я новичок в латексе и застрял в форматировании и выравнивании таблицы. Я также приложил скриншот.

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 голосов
/ 28 марта 2019

Вы можете использовать пакет siunitx . Он определяет новый тип столбца S, который выравнивает числа по их десятичной точке.

Пакет был полностью нарушен вашей слишком сложной таблицей со многими вложенными таблицами. В общем, вам никогда не нужно этого делать. Я переписал вашу таблицу намного проще и понятнее.

Обратите внимание, что для столбца 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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...