如何使用與 MWE 中相同的格式建立此表?

如何使用與 MWE 中相同的格式建立此表?

使用如下佈局:

\documentclass{article}

\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\begin{document}
\begin{center}
    \begin{tblr}{ colspec = {Q[l, mode=math] Q[c, si={table-format=-1.4}]},
                  row{1}  = {guard, mode=text},
                 row{2-Z} = {rowsep=0pt},
                  row{2}  = {abovesep=2pt},
                 row{odd[3-Z]} = {belowsep=0.5ex},
                }
    \toprule
Expression  &   Value   \\
     \toprule
a^2 + b^2   & -1.2345       \\
a^2 + b^2   & -1.2345       \\
a^2 + b^2   & -1.2345       \\
a^2 + b^2   & -1.2345       \\
a^2 + b^2   & -1.2345       \\
    \bottomrule
    \end{tblr}
\end{center}
\end{document}

我們如何建立下表?

\documentclass{article}
    
    \usepackage{tabularray}
    \UseTblrLibrary{booktabs, siunitx}
    
    \begin{document}
\begin{center}
\captionof{table}{Parameter values used in numerical simulations of system.}
\label{tab1}
\begin{tabular}{c|c|c|c|c|c|c|c|c|c|c|c}
\hline
 & \beta & \mu & \alpha_{1} & p_{1} & \phi & \xi & \psi & p_{2} & p_{3} & \theta & \alpha_{2} \\
\hline
\hline
State 1  & 0.2 & 0.2 & 0.12 & 0.11 & 0.1 & 0.11 & 0.1 & 0.12 & 0.11 & 0.1 & 0.1\\
\hline
State 2  & 0.21 & 0.22 & 0.11 & p_{1} & 0.1 & 0.11 & 0.12 & 0.1 & 0.11 & 0.1 & 0.11\\
\hline
\end{tabular}
\end{center}
\end{document}

在此輸入影像描述

答案1

通常有助於閱讀有關表格的介紹文字。閱讀使用過的軟體包文件也很有幫助。包tabularray有簡潔且非常清晰的文件。非常值得一讀。

編輯:
呃,我忘了表格標題。現在新增...

\documentclass{article}
\usepackage[skip=1ex, font=small, labelfont=bf]{caption}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\begin{document}
    \begin{table}[ht]
    \centering
\caption{Parameter values used in numerical simulations of system.}
\begin{tblr}{hlines, vline{2-Y}=solid,
             colspec = {l *{11}{Q[c, si={table-format=1.2}]}},
             cell{1}{2-Z}  = {guard, mode=math},
             }
        & \beta & \mu   & \alpha_1  & p_1   & \phi  & \xi   & \psi  & p_2   & p_3   & \theta    & \alpha_2  \\
State 1 & 0.2   & 0.2   & 0.12      & 0.11  & 0.1   & 0.11  & 0.1   & 0.12  & 0.11  & 0.1       & 0.1       \\
State 2 & 0.21  & 0.22  & 0.11      & \SetCell{guard, c, $} p_1   
                                            & 0.1   & 0.11  & 0.12  & 0.1   & 0.11  & 0.1       & 0.11      \\
\end{tblr}
    \end{table}
\end{document}

在此輸入影像描述

相關內容