你會如何設計下表?

你會如何設計下表?

我的目標是以簡潔的方式展示在資料集 R1、R2 和 R3 上訓練的模型所達到的測試精度。為了實現這一目標,我分多個階段訓練模型,逐漸合併三組中每一組的更多數據,而不是立即從整個數據集開始。 在此輸入影像描述

你怎麼看待這件事?我不太確定是否可以避免為每個模型重複資料集名稱。如果有任何建議,我將不勝感激

答案1

我的主要建議是調換材料,這樣你就只有 4 或 5 列,而不是 10 或更多。

在此輸入影像描述

\documentclass{article}
\usepackage{array,booktabs}
\usepackage[flushleft]{threeparttable}

\begin{document}

\begin{table}[h]
\centering
\begin{threeparttable}
\caption{Test accuracies achieved by models trained on datasets R1, R2, and~R3}
\begin{tabular}{@{} ll ccc @{}}
\toprule
\multicolumn{2}{@{}l@{}}{Model} & \multicolumn{3}{c@{}}{Training Phases} \\
\cmidrule(l){3-5} 
&& Phase 1 & Phase 2 & Phase 3 \\
\midrule
\multicolumn{2}{@{}l@{}}{Decision Tree} \\
& R1 & \dots & \dots & \dots \\
& R2 & \dots & \dots & \dots \\
& R3 & \dots & \dots & \dots \\
\addlinespace
\multicolumn{2}{@{}l@{}}{LSTU} \\
& R1 & \dots & \dots & \dots \\
& R2 & \dots & \dots & \dots \\
& R3 & \dots & \dots & \dots \\
\addlinespace
\multicolumn{2}{@{}l@{}}{Average} \\
& R1 & \dots & \dots & \dots \\
& R2 & \dots & \dots & \dots \\
& R3 & \dots & \dots & \dots \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}

\end{document}

附錄解決OP的後續評論/請求:要在上表中插入一個新的居中對齊的列並使用“Baseline”作為新標題的內容,您需要做的主要更改是替換

\begin{tabular}{@{} ll ccc @{}}

\begin{tabular}{@{} ll c ccc @{}}

接下來,改變

\cmidrule(l){3-5}

\cmidrule(l){4-6}

當然,不要忘記在表中插入新第 3 列的內容—每行 1 個儲存格。

在此輸入影像描述

\documentclass{article}
\usepackage{array,booktabs}
\usepackage[flushleft]{threeparttable}
\newcommand\ML[1]{\multicolumn{2}{@{}l}{#1}} % handy shortcut macro

\begin{document}

\begin{table}[h]
\centering
\begin{threeparttable}
\caption{Test accuracies achieved by models trained on datasets R1, R2, and~R3}
\begin{tabular}{@{} ll c ccc @{}}
\toprule
\ML{Model} & Baseline & \multicolumn{3}{c@{}}{Training Phases} \\
\cmidrule(l){4-6} 
&&& Phase 1 & Phase 2 & Phase 3 \\
\midrule
\ML{Decision Tree} \\
& R1 & \dots & \dots & \dots & \dots \\
& R2 & \dots & \dots & \dots & \dots \\
& R3 & \dots & \dots & \dots & \dots \\
\addlinespace
\ML{LSTU} \\
& R1 & \dots & \dots & \dots & \dots \\
& R2 & \dots & \dots & \dots & \dots \\
& R3 & \dots & \dots & \dots & \dots \\
\addlinespace
\ML{Average} \\
& R1 & \dots & \dots & \dots & \dots \\
& R2 & \dots & \dots & \dots & \dots \\
& R3 & \dots & \dots & \dots & \dots \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}

\end{document}

答案2

我認為重複這些名字並不算太糟。我想出了以下內容。根據您的數據,您可能想要使用套件S中的列siunitx和/或將文字顯示為粗體 ( \textbf{...})。 在此輸入影像描述

\documentclass{article}
\usepackage{booktabs,multirow}

\begin{document}
    \begin{tabular}{llllllllll}
        \toprule
        \multirow{2}{*}{Training phases} & \multicolumn{3}{c}{Decision Tree} & \multicolumn{3}{c}{LST M} & \multicolumn{3}{c}{Average} \\ \cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){8-10}
                                         & R1     & R2     & R3              & R1     & R2     & R3      & R1     & R2     & R3        \\ \midrule
        Training phase 1                 & \ldots & \ldots & \ldots          & \ldots & \ldots & \ldots  & \ldots & \ldots & \ldots    \\
        Training phase 2                 & \ldots & \ldots & \ldots          & \ldots & \ldots & \ldots  & \ldots & \ldots & \ldots    \\
        Training phase 3                 & \ldots & \ldots & \ldots          & \ldots & \ldots & \ldots  & \ldots & \ldots & \ldots    \\ \bottomrule
    \end{tabular}
\end{document}

答案3

如果我看到這些畫面,請使用 Excel2latex。這是一個強大的 Excel 宏,可以自動編輯 Excel 中的程式碼 LATEX。這是超級好的,也是開放取用的一部分。請諮詢「Reed me」宏,以了解使用所需的軟體包(bigstruth、colortbl、multirow 等)。

完成後,您將在 Excel 上建立表格。 Puis,您的選擇和「將桌子轉換為乳膠」的小組。其次,您將獲得畫面選擇乳膠代碼的產品。

答案4

當我需要製作這樣的表格時,我使用Excel2latex。這是一個很棒的 Excel 巨集,可以自動重現 Excel 表格的 LaTeX 程式碼。它效果很好,並且可以通過開放獲取在線獲取。您必須檢查巨集的「自述檔案」以查看使用它所需的套件(bigstruth、colortbl、multirow 等)。

使用此工具,您可以在 Excel 中建立表格。然後選擇它並點擊“將表格轉換為 LaTeX”。一秒鐘內,它會產生所選表格的 LaTeX 程式碼。

相關內容