我正在尝试在 LaTeX(Overleaf)中重现按国家年份划分的汇总统计表。
我得到的表格超出了宽度,我无法使用我在这里或其他论坛中看到的其他问题的解决方案来解决这个问题。下面是表格超出宽度的代码。有没有办法让它打破列并用剩余的国家年份开始表格的全新部分?我的真实数据包含的国家年份甚至比这还要多。
\documentclass[
12pt,
openright,
twoside,
a4paper,
english,
french,
spanish,
brazil
]{abntex2}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\usepackage{indentfirst}
\usepackage{color}
\usepackage{graphicx}
\usepackage{microtype}
\begin{document}
\begin{tabular}{l|l|l|l|l|l|l|l|l|l|l}
\hline
Summary Statistics Table for the Gapminder Data Set & ARG_2015 (N = 1406) & BRA_2002 (N = 2514) & BRA_2006 (N = 1000) & BRA_2010 (N = 2000) & BRA_2014 (N = 3136) & CHL_1999 (N = 1173) & CHL_2005 (N = 1200) & CHL_2009 (N = 1200) & FRA_2002 (N = 1000) & FRA_2012 (N = 2014)\\
\hline
\bf{Conhecimento} & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~\\
\hline
~~ mean (sd) & 1,405; 0.35 $\pm$ 0.29 & 0.50 $\pm$ 0.35 & 0.59 $\pm$ 0.29 & 1,999; 0.48 $\pm$ 0.25 & 3,124; 0.19 $\pm$ 0.24 & 0; NaN $\pm$ NA & 1,194; 0.85 $\pm$ 0.26 & 1,197; 0.49 $\pm$ 0.40 & 0.49 $\pm$ 0.28 & 2,011; 0.45 $\pm$ 0.32\\
\hline
~~ median (Q1, Q3) & 1,405; 0.50 (0.00, 0.50) & 0.67 (0.33, 0.67) & 0.67 (0.33, 0.67) & 1,999; 0.33 (0.33, 0.67) & 3,124; 0.00 (0.00, 0.25) & 0; NA ( NA, NA) & 1,194; 1.00 (0.67, 1.00) & 1,197; 0.50 (0.00, 1.00) & 0.33 (0.33, 0.67) & 2,011; 0.50 (0.25, 0.75)\\
\hline
~~ min & 0 & 0 & 0 & 0 & 0 & Inf & 0 & 0 & 0 & 0\\
\hline
~~ max & 1 & 1 & 1 & 1 & 1 & -Inf & 1 & 1 & 1 & 1\\
\hline
~~ Missing & 1 & 0 & 0 & 1 & 12 & 1173 & 6 & 3 & 0 & 3\\
\hline
\bf{Population} & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~ & ~\\
\hline
~~ mean (sd) & 7.28 $\pm$ 0.00 & 9.07 $\pm$ 0.00 & 13.37 $\pm$ 0.00 & 12.31 $\pm$ 0.00 & 0.42 $\pm$ 0.00 & 11.61 $\pm$ 0.00 & 18.00 $\pm$ 0.00 & 7.49 $\pm$ 0.00 & 7.19 $\pm$ 0.00 & 0.03 $\pm$ 0.00\\
\hline
~~ median (Q1, Q3) & 7.28 (7.28, 7.28) & 9.07 (9.07, 9.07) & 13.37 (13.37, 13.37) & 12.31 (12.31, 12.31) & 0.42 (0.42, 0.42) & 11.61 (11.61, 11.61) & 18.00 (18.00, 18.00) & 7.49 (7.49, 7.49) & 7.19 (7.19, 7.19) & 0.03 (0.03, 0.03)\\
\hline
~~ min & 7.27983820530003 & 9.0691721405 & 13.3688332656 & 12.3130505024 & 0.420588274400036 & 11.6114849984 & 18.0004356286 & 7.4901184544 & 7.18576082240001 & 0.0300030000999874\\
\hline
~~ max & 7.27983820530003 & 9.0691721405 & 13.3688332656 & 12.3130505024 & 0.420588274400036 & 11.6114849984 & 18.0004356286 & 7.4901184544 & 7.18576082240001 & 0.0300030000999874\\
\hline
~~ Missing & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
\hline
\end{tabular}
\end{document}
答案1
如下例所示,将表格拆分成两部分可以使其出现在单个横向页面上:
\documentclass{article}
\usepackage{array}
\usepackage{geometry}
\usepackage{pdflscape}
\usepackage{booktabs}
\begin{document}
\begin{landscape}
\begin{table}
\small
\centering
\caption{Summary Statistics Table for the Gapminder Data Set}
\begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}*{5}{wl{2.8cm}}}
\toprule
& ARG\_2015 & BRA\_2002 & BRA\_2006 & BRA\_2010 & BRA\_2014 \\
& (N = 1406) & (N = 2514) & (N = 1000) & (N = 2000) & (N = 3136) \\
\midrule
\multicolumn{1}{@{}l}{\textbf{Conhecimento}}\\
mean (sd) & 1,405; 0.35 $\pm$ 0.29 & 0.50 $\pm$ 0.35 & 0.59 $\pm$ 0.29 & 1,999; 0.48 $\pm$ 0.25 & 3,124; 0.19 $\pm$ 0.24 \\
median & 1,405; 0.50 & 0.67 & 0.67 & 1,999; 0.33 & 3,124; 0.00 \\
(Q1, Q3) & (0.00, 0.50) & (0.33, 0.67) & (0.33, 0.67) & (0.33, 0.67) & (0.00, 0.25) \\
min & 0 & 0 & 0 & 0 & 0 \\
max & 1 & 1 & 1 & 1 & 1 \\
Missing & 1 & 0 & 0 & 1 & 12 \\
\midrule
\multicolumn{1}{@{}l}{\textbf{Population}} \\
mean (sd) & 7.28 $\pm$ 0.00 & 9.07 $\pm$ 0.00 & 13.37 $\pm$ 0.00 & 12.31 $\pm$ 0.00 & 0.42 $\pm$ 0.00 \\
median & 7.28 & 9.07 & 13.37 & 12.31 & 0.42 \\
(Q1, Q3) & (7.28, 7.28) & (9.07, 9.07) & (13.37, 13.37) & (12.31, 12.31) & (0.42, 0.42) \\
min & 7.27983820530003 & 9.0691721405 & 13.3688332656 & 12.3130505024 & 0.420588274400036 \\
max & 7.27983820530003 & 9.0691721405 & 13.3688332656 & 12.3130505024 & 0.420588274400036 \\
Missing & 0 & 0 & 0 & 0 & 0 \\
\midrule
%Summary Statistics Table for the Gapminder Data Set
& CHL\_1999 & CHL\_2005 & CHL\_2009 & FRA\_2002 & FRA\_2012 \\
& (N = 1173) & (N = 1200) & (N = 1200) & (N = 1000) & (N = 2014)\\
\midrule
\multicolumn{1}{@{}l}{\textbf{Conhecimento}}\\
mean (sd) & 0; NaN $\pm$ NA & 1,194; 0.85 $\pm$ 0.26 & 1,197; 0.49 $\pm$ 0.40 & 0.49 $\pm$ 0.28 & 2,011; 0.45 $\pm$ 0.32\\
median & 0; NA & 1,194; 1.00 & 1,197; 0.50 & 0.33 & 2,011; 0.50\\
(Q1, Q3) & (NA, NA) & (0.67, 1.00) & (0.00, 1.00) & (0.33, 0.67) & (0.25, 0.75)\\
min & Inf & 0 & 0 & 0 & 0\\
max & -Inf & 1 & 1 & 1 & 1\\
Missing & 1173 & 6 & 3 & 0 & 3\\
\midrule
\multicolumn{1}{@{}l}{\textbf{Population}} \\
mean (sd) & 11.61 $\pm$ 0.00 & 18.00 $\pm$ 0.00 & 7.49 $\pm$ 0.00 & 7.19 $\pm$ 0.00 & 0.03 $\pm$ 0.00\\
median & 11.61 & 18.00 & 7.49 & 7.19 & 0.03 \\
(Q1, Q3) & (11.61, 11.61) & (18.00, 18.00) & (7.49, 7.49) & (7.19, 7.19) & (0.03, 0.03)\\
min & 11.6114849984 & 18.0004356286 & 7.4901184544 & 7.18576082240001 & 0.0300030000999874\\
max & 11.6114849984 & 18.0004356286 & 7.4901184544 & 7.18576082240001 & 0.0300030000999874\\
Missing & 0 & 0 & 0 & 0 & 0\\
\bottomrule
\end{tabular*}
\end{table}
\end{landscape}
\end{document}