如何在Latex中表示這些形式的數據?

如何在Latex中表示這些形式的數據?

第一個是帶有“進程ID”的,我認為這可以用表來完成,但不知道如何做。

在第二個中,我想到了equation這一點,但無法弄清楚如何將資料放置在矩陣之外,而且在它的左側也沒有方程式的表示

答案1

我認為第一個表有兩個主要挑戰:

  • 如何使其適合文字區塊?基本tabular環境並不能保證這個 17 列的表格實際上適合。

  • 如何排版標題行(“進程 ID...”)?

為了應對這些挑戰,我建議您採用 (a)tabular*寬度設定為 的環境\textwidth和 (b)\multicolumn指令,如下面的程式碼所示。順便說一句,我會右對齊數字而不是左對齊。

第三個挑戰可能是如何用淺灰色背景渲染整個表格材質。在下面的程式碼中,我使用了中提出的技術這個答案來應對這項挑戰。

關於第二個表,我想說將數字材料設定為由大括號包圍的(數學)矩陣是不正確的。更重要的是將標題單元格與其相應的列對齊。另外,我還想說,為了易讀性,將數字在各自的小數點上對齊很重要。因此,我將使用一個tabular環境以及四個「真實」資料列的套件S的列類型。siunitx

在此輸入影像描述

\documentclass{article}
\usepackage{booktabs,siunitx,xcolor}
\definecolor{lightgray}{gray}{0.85} % define a suitable version of "light gray"
\newcommand\mytab[1]{\smash{%
   \begin{tabular}[t]{@{}c@{}}#1\end{tabular}}}

\begin{document}

\noindent
\begingroup % localize scope of next two instructions
\setlength\tabcolsep{0pt} % make LaTeX figure out inter-column whitespace
\setlength\fboxsep{0pt}   % see https://tex.stackexchange.com/a/63897/5001
\colorbox{lightgray}{%
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{17}{r}}
\toprule
\multicolumn{6}{@{}l}{Process ID: 3939}\\[0.5ex]
105 & 104& 104& 106& 105& 104& 104& 106& 105& 104& 104& 106& 5& 4& 5& 5 &0 \\
40 & 41 & \dots \\
3  &  3 & \dots \\
3  & 12 & \dots \\
\bottomrule
\end{tabular*}}
\endgroup

\bigskip

\begin{center}
\begin{tabular}{@{}c *{2}{S[table-format=1.3]} 
    c *{2}{S[table-format=1.3]} @{}}
\toprule
\mytab{Distinct\\System Call} & 
\multicolumn{5}{c}{Trace} \\
\cmidrule(l){2-6}
  & {1}   & {2}   &       & {$m-1$} & {$m$}   \\
\midrule
1  & 0.051  & 0.055  & \dots  & 0.049 & 0.051 \\
2  & 0.122  & 0.125  & \dots  & \\
   &{\vdots}&{\vdots}&{\vdots}& \\
155& 0.101  & 0.1    & \dots  & \\
167& 0.03   & 0.03   & \dots  & 0.02  & 0.03  \\
\bottomrule
\end{tabular}
\end{center}

\end{document}

相關內容