# Making widths of tables equal to width of textblock [duplicate]

I have various tables in my document, and all of them have different widths. Is there a way I can evenly space out all of them, and have all widths equal to the width of the textblock (=pagewidth minus widths of margins)?

\documentclass[12pt]{article}
\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}

\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}
\fancyfoot{}
\fancyfoot[R]{ \thepage\ }
\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
& \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                                                               \\
%%%%
\caption{Summary statistics 2 (cont.)} \\ \toprule
& \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}

• For simple tables check here : tex.stackexchange.com/questions/10535/… ... For longtable check here: tex.stackexchange.com/questions/110266/… ... Off topic try to use caption only above or only below your tables. Your question is a duplicate of the first or second link. I would say with the first since you just added langtable as a tag and don't asking anything about this Sep 6 '17 at 17:18
• What's the reason for setting the value of \clubpenalty twice?
– Mico
Sep 6 '17 at 17:45
• @Mico sorry about that, did not notice the repetition. I'll edit that. Sep 6 '17 at 17:58

For the first table, I suggest you use a tabular* environment, with width set to \textwidth, inside a table environment (not a table* environment). For the longtable, I suggest you use an @{\extracolsep{\fill}} directive in the argument of the environment.

I would also strive for a less-cluttered look in the tables, say, by omitting as many horizontal lines as possible.

I have no idea how you defined the instruction \helvet. I've assumed you want it to mean, "switch to Helvetica for the table material". To do so, I've loaded the helvet package and I've replaced both instances of \helvet with \sffamily.

\documentclass[12pt]{article}
\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}

\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}
\fancyfoot{}
\fancyfoot[R]{ \thepage\ }
\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
& \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
%%%%
\caption{Summary statistics 2 (cont.)} \\
\toprule
& \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

\midrule
\multicolumn{8}{r}{\footnotesize\textit{Continue on the next page}}
\endfoot

\bottomrule
\endlastfoot

\mceight{\textbf{PANEL A: 2011--2012}} \\
\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}

• thanks for the help. The helvet and changing font size wasn't doing any good, so shifted to using \footnotesize Sep 6 '17 at 17:38
• Also, the caption for the first table comes at the bottom every time. Something evidently wrong in what I am doing? Sep 6 '17 at 17:39
• @KushaVerma - If the first table's caption is being placed below rather than above the tabular material in your document, it's probably because the \caption instruction occurs after, rather than before, the tabular (or tabular*) environment. (Observe the position of the caption in the screenshot above.)
– Mico
Sep 6 '17 at 17:44
• @KushaVerma - The reason \fontsize{10}{12} wasn't working for you is that you failed to provide the instruction \selectfont. See my code for how to use \fontsize correctly.
– Mico
Sep 6 '17 at 17:50
• Even when I do as you suggested, I get the caption at the bottom of the table\begin{table}[ht] \caption{Summary statistics 1} \sisetup{detect-all} \setlength\tabcolsep{0pt} \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 Sep 6 '17 at 17:56