![我想制作这样的表格。但我无法制作特定的表格](https://linux22.com/image/389995/%E6%88%91%E6%83%B3%E5%88%B6%E4%BD%9C%E8%BF%99%E6%A0%B7%E7%9A%84%E8%A1%A8%E6%A0%BC%E3%80%82%E4%BD%86%E6%88%91%E6%97%A0%E6%B3%95%E5%88%B6%E4%BD%9C%E7%89%B9%E5%AE%9A%E7%9A%84%E8%A1%A8%E6%A0%BC.png)
\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\begin{document}
\begin{table}
\begin{tabular}{lSSSSSS}
\toprule
\multirow{3}{0.3cm}{} &
\multicolumn{3}{c}{Baripada } &
\multicolumn{3}{c}{Jagatsinghpur} \\
\hline
& {Absolute Frequency } & {Frequency(\%)} & {Cumulative Frequency} & {Absolute Frequency} & {Frequency(\%)} & {Cumulative Frequency} \\
\midrule
Recently & 0& 0.00& 0 &6& 3.33& 6 \\
More than 5 years & 3& 1.67& 3 &47& 26.11 &53\\
Less than 10 years & 47& 26.11 &50& 14 &7.78& 67 \\
More than 10 years & 58& 32.22& 108& 20 &11.11& 87 \\
Since the party formed & 72& 40.00& 180& 93& 51.67& 180 \\\hline
Toatal& 180&100&*&180&100&*\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
- 您的表格太宽,无法放入页面的文本区域
- 你有两种选择:
- 使用列标题的缩写,并将其含义写为表格下方的表格注释(因为这可以通过包轻松完成
threeparttable
) - 使文本区域更宽(通过使用包
geometry
)并将列标题写成两行(使用\thead
包中的宏makecell
)
- 使用列标题的缩写,并将其含义写为表格下方的表格注释(因为这可以通过包轻松完成
第一种情况:
\documentclass{article} \usepackage{booktabs, threeparttable} \usepackage{siunitx} %---------------- show page layout. don't use in a real document! \usepackage{showframe} \renewcommand\ShowFrameLinethickness{0.15pt} \renewcommand*\ShowFrameColor{\color{red}} %---------------------------------------------------------------% \begin{document} \begin{table} \setlength\tabcolsep{0pt} \begin{threeparttable}[htb] \caption{My table} \label{tab:mytable} \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l *{2}{S[table-format=3.0] S[table-format=3.2] S[table-format=3.0]} } \toprule & \multicolumn{3}{c}{Baripada} & \multicolumn{3}{c}{Jagatsinghpur} \\ \cmidrule{2-4}\cmidrule{5-7} & {AF\tnote{a}} & {F\tnote{b} (\%)} & {CF\tnote{c}} & {AF\tnote{a}} & {F\tnote{b} (\%)} & {CF\tnote{c}} \\ \midrule Recently & 0 & 0.00 & 0 & 6 & 3.33 & 6 \\ More than 5 years & 3 & 1.67 & 3 & 47 & 26.11 & 53 \\ Less than 10 years & 47 & 26.11 & 50 & 14 & 7.78 & 67 \\ More than 10 years & 58 & 32.22 & 108 & 20 & 11.11 & 87 \\ Since the party formed & 72 & 40.00 & 180 & 93 & 51.67 & 180 \\ \midrule Toatal & 180 & 100 & * & 180 & 100 & * \\ \midrule[\heavyrulewidth] \end{tabular*} \begin{tablenotes}[para,flushleft]\footnotesize \item[a] Absolute Frequency \item[b] Frequency \item[c] Cumulative Frequency \end{tablenotes} \end{threeparttable} \end{table} \end{document}
(红线表示文本边框)
第二种情况
\documentclass{article} \usepackage{geometry} \usepackage{booktabs, makecell} \renewcommand\theadfont{\normalsize} \renewcommand\theadgape{} \usepackage{siunitx} \begin{document} \begin{table} \setlength\tabcolsep{0pt} \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} l *{2}{S[table-format=3.0] S[table-format=3.2] S[table-format=3.0]} } \toprule & \multicolumn{3}{c}{Baripada} & \multicolumn{3}{c}{Jagatsinghpur} \\ \cmidrule{2-4}\cmidrule{5-7} & {\thead{Absolute\\ Frequency}} & {\thead{Frequency\\ (\%)}} & {\thead{Cumulative\\ Frequency}} & {\thead{Absolute\\ Frequency}} & {\thead{Frequency\\ (\%)}} & {\thead{Cumulative\\ Frequency}} \\ \midrule Recently & 0 & 0.00 & 0 & 6 & 3.33 & 6 \\ More than 5 years & 3 & 1.67 & 3 & 47 & 26.11 & 53 \\ Less than 10 years & 47 & 26.11 & 50 & 14 & 7.78 & 67 \\ More than 10 years & 58 & 32.22 & 108 & 20 & 11.11 & 87 \\ Since the party formed & 72 & 40.00 & 180 & 93 & 51.67 & 180 \\ \midrule Toatal & 180 & 100 & * & 180 & 100 & * \\ \bottomrule \end{tabular*} \end{table} \end{document}