表中先有 2 列,後面接著 5 列(多列)

表中先有 2 列,後面接著 5 列(多列)

我這裡有問題。我需要製作一張這樣的桌子。然而,該網站上的問題和答案似乎都沒有幫助。我嘗試過使用他們提供的程式碼(以適合我的標籤)進行實驗,但無濟於事。請問你能幫我解決這個問題嗎?

在此輸入影像描述

答案1

您可以用來\multicolum{2}{c}{...}建立一個跨兩個欄位的居中儲存格。

在此輸入影像描述

\documentclass{article}
\usepackage{booktabs} % provides the \toprule, \midrule and \bottomrule macros
\begin{document}
\begin{tabular}{l *{4}{c}}
\toprule
 & \multicolumn{2}{c}{\textbf{Non-taxed}} & \multicolumn{2}{c}{\textbf{Taxed}} \\ \midrule
Store type & Dec 2014 & Jun 2015 & Dec 2014 & Jun 2015 \\ \midrule
1 \\
3 \\
\bottomrule
\end{tabular}
\end{document}

答案2

這是一個變體托比昂的回答。 (主要區別在於使用幾個\cmidrule指令來代替一個\midrule指令。)

在此輸入影像描述

\documentclass{article} % or some other suitable document class
\usepackage{booktabs} % for well-spaced horizontal rules
\begin{document}
\begin{center}
\begin{tabular}{@{} l *{4}{c} @{}}
\toprule
& \multicolumn{2}{c}{\textbf{Non-taxed}} & \multicolumn{2}{c@{}}{\textbf{Taxed}} \\
\cmidrule(lr){2-3} \cmidrule(l){4-5}
Store type & Dec 2014 & Jun 2015 & Dec 2014 & Jun 2015 \\
\midrule
1 \\
3 \\
\bottomrule
\end{tabular}
\end{center}

\end{document}

相關內容