我的文档中有各种表格,并且所有表格的宽度都不同。有没有办法可以均匀分布所有表格,并使所有表格的宽度等于文本块的宽度(=页面宽度减去边距宽度)?
\documentclass[12pt]{article}
\addtolength{\parskip}{\baselineskip}
\usepackage[margin=1in,includefoot]{geometry}
\usepackage[fleqn]{amsmath}
\usepackage{mathtools}
\usepackage{siunitx}
%Tables preamble
\usepackage[none]{hyphenat}
\usepackage{array}
\usepackage[thinlines]{easytable}
\usepackage{longtable}
\usepackage{array, booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mceight[1]{\multicolumn{8}{l}{#1}}
\newcommand\mctwelve[1]{\multicolumn{12}{c}{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage{pdflscape}
\usepackage{afterpage}
\widowpenalty500
\clubpenalty500
\exhyphenpenalty=50 %for line-breaking at an explicit hyphen
\brokenpenalty=4991
\predisplaypenalty=10000
\postdisplaypenalty=1549
\displaywidowpenalty=1602
\floatingpenalty = 20000
% Header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyfoot[R]{ \thepage\ }
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{1pt}
\usepackage{booktabs}
\usepackage{dcolumn}
\begin{document}
\subsection{Appendix of Tables}
\newgeometry{margin=0.5in}
\begin{table*}[ht] \centering
\fontsize{10}{12}\helvet
\caption{Summary statistics 1}
\begin{tabular}{l*{6}{S[table-format=2.2]}} \toprule
& & & \multicolumn{3}{c}{Quantiles} \\ \cmidrule(lr){4-6}
\textbf{Variable} & \textbf{Mean} & \textbf{Minimum} & \textbf{25th percentile} & \textbf{Median} & \textbf{75th percentile} & \textbf{Maximum} \\ \midrule
\textbf{Panel A: Female labour force} \\ \midrule
\textbf{2004-05} \\ \hdashline
{Hourly wage} & 17.17 & 0 & 3.75 & 5.48 & 12.5 & 250\ \\ \hdashline
{Age (in years)}& 9.98 & 15 & 22 & 29 & 38 & 60\ \\ \hdashline
{Years of experience} & 10.61 & 0 & 8 & 15 & 25 & 40\ \\ \hdashline
{Years of education} & 7.13 & 0 & 0 & 8 & 12 & 16\ \\ \hdashline
\\ \bottomrule
\end{tabular}
\end{table*}
\begin{longtable}{ l*{7}{S[table-format=2.2]} }
\fontsize{10}{12}\helvet
\caption{Summary statistics 2}
\label{tab:...} \\
\toprule
\multirow[b]{2}{*}{\thead{Dependent\\ Variables}}
& \multicolumn{3}{c}{\thead[b]{Share(\%)}}
& \multicolumn{3}{c}{\thead[b]{Avg hourly wage}}
& {\multirow[b]{2}{*}{\thead{Avg\\ differential}}} \\
\cmidrule(lr){2-4}\cmidrule(lr){5-7}
& \textbf{Men} & \textbf{Women} & \textbf{Pooled}
& \textbf{Men} & \textbf{Women} & \textbf{Pooled} \\
\hdashline \\
\endfirsthead
%%%%
\caption{Summary statistics 2 (cont.)} \\ \toprule
\multirow[b]{2}{*}{\thead{Dependent\\ Variables}}
& \multicolumn{3}{c}{\thead[b]{Share(\%)}}
& \multicolumn{3}{c}{\thead[b]{Avg hourly wage}}
& {\multirow[b]{2}{*}{\thead{Avg\\ differential}}} \\
\cmidrule(lr){2-4} \cmidrule(lr){5-7}
& \textbf{Men} & \textbf{Women} & \textbf{Pooled} & \textbf{Men} &
\textbf{Women} & \textbf{Pooled} \\ \midrule \\ \endhead \midrule
\multicolumn{8}{r}{\footnotesize\textit{Continue on the next page}}
\endfoot\endlastfoot
\mceight{\textbf{PANEL A: 2011-2012}} \\ \midrule
\\
\mceight{\textbf{Panel A.1: Sector (Urban or Rural)}} \\ \midrule
Rural & 51.5 & 54 & 52 & 28.54 & 18.83 & 26.92 & 51.5 \\ \hdashline
Urban & 48.4 & 46 & 48 & 45.19 & 41.86 & 45 & 7.8 \\ \hdashline
\bottomrule
\end{longtable}
\end{document}
答案1
对于第一个表,我建议您使用一个tabular*
环境,将宽度设置为\textwidth
,在table
环境内(不是环境table*
)。对于longtable
,我建议您@{\extracolsep{\fill}}
在环境参数中使用指令。
我还会努力使表格看起来不那么杂乱,比如,尽可能地省略水平线。
我不知道您是如何定义指令的\helvet
。我假设您希望它表示“将表格材质切换为 Helvetica”。为此,我加载了包,helvet
并将两个实例替换\helvet
为\sffamily
。
\documentclass[12pt]{article}
\addtolength{\parskip}{\baselineskip}
\usepackage[margin=1in,includefoot]{geometry}
\usepackage[fleqn]{amsmath}
\usepackage{mathtools}
\usepackage{siunitx,helvet}
%Tables preamble
\usepackage[none]{hyphenat}
\usepackage[thinlines]{easytable}
\usepackage{longtable}
\usepackage{array, booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries\small}
\newcommand\mceight[1]{\multicolumn{8}{@{}l}{#1}}
\newcommand\mctwelve[1]{\multicolumn{12}{@{}c}{#1}}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\usepackage{pdflscape}
\usepackage{afterpage}
\widowpenalty500
\clubpenalty500
\clubpenalty=9996
\exhyphenpenalty=50 %for line-breaking at an explicit hyphen
\brokenpenalty=4991
\predisplaypenalty=10000
\postdisplaypenalty=1549
\displaywidowpenalty=1602
\floatingpenalty = 20000
% Header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyfoot[R]{ \thepage\ }
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{1pt}
\usepackage{booktabs}
\usepackage{dcolumn}
\begin{document}
\subsection{Appendix of Tables}
%\newgeometry{margin=0.5in}
\begin{table}[ht]
\fontsize{10}{12}\selectfont
\sffamily
\sisetup{detect-all}
\setlength\tabcolsep{0pt}
\caption{Summary statistics 1}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
l S[table-format=2.2] S[table-format=2.0]
*{3}{S[table-format=2.2]} S[table-format=3.0]}
\toprule
& & & \multicolumn{3}{c}{Quantiles} \\
\cmidrule{4-6}
\textbf{Variable} & \textbf{Mean} & \textbf{Min.} &
\textbf{25th percentile} & \textbf{Median} &
\textbf{75th percentile} & \textbf{Max.} \\
\midrule
\textbf{Panel A: Female labour force} \\
\midrule
\textbf{2004--05} \\ %\hdashline
Hourly wage & 17.17 & 0 & 3.75 & 5.48 & 12.5 & 250\\ %\hdashline
Age (in years) & 9.98 & 15 & 22 & 29 & 38 & 60\\ %\hdashline
Years of experience & 10.61 & 0 & 8 & 15 & 25 & 40\\ %\hdashline
Years of education & 7.13 & 0 & 0 & 8 & 12 & 16\\ %\hdashline
\bottomrule
\end{tabular*}
\end{table}
\begingroup % localize to 'longtable' env.
\fontsize{10}{12}\selectfont
\sffamily
\sisetup{detect-all}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\tabcolsep{0pt}
\begin{longtable}{@{\extracolsep{\fill}} l *{7}{S[table-format=2.2]} }
\caption{Summary statistics 2} \label{tab:...} \\
\toprule
\multirow[b]{2}{*}{\thead{Dependent\\ Variables}}
& \multicolumn{3}{c}{\thead[b]{Share (\%)}}
& \multicolumn{3}{c}{\thead[b]{Avg hourly wage}}
& {\multirow[b]{2}{*}{\thead{Avg\\ differential}}} \\
\cmidrule{2-4}\cmidrule{5-7}
& \textbf{Men} & \textbf{Women} & \textbf{Pooled}
& \textbf{Men} & \textbf{Women} & \textbf{Pooled} \\
\midrule
\endfirsthead
%%%%
\caption{Summary statistics 2 (cont.)} \\
\toprule
\multirow[b]{2}{*}{\thead{Dependent\\ Variables}}
& \multicolumn{3}{c}{\thead[b]{Share (\%)}}
& \multicolumn{3}{c}{\thead[b]{Avg hourly wage}}
& {\multirow[b]{2}{*}{\thead{Avg\\ differential}}} \\
\cmidrule{2-4} \cmidrule{5-7}
& \textbf{Men} & \textbf{Women} & \textbf{Pooled} & \textbf{Men}
& \textbf{Women} & \textbf{Pooled} \\
\midrule
\endhead
\midrule
\multicolumn{8}{r}{\footnotesize\textit{Continue on the next page}}
\endfoot
\bottomrule
\endlastfoot
\mceight{\textbf{PANEL A: 2011--2012}} \\
\addlinespace
\mceight{\textbf{Panel A.1: Sector (Urban or Rural)}} \\ \addlinespace
Rural & 51.5 & 54 & 52 & 28.54 & 18.83 & 26.92 & 51.5 \\ %\hdashline
Urban & 48.4 & 46 & 48 & 45.19 & 41.86 & 45 & 7.8 \\ %\hdashline
\end{longtable}
\endgroup
\end{document}