LaTeX forum ⇒ MiKTeX and proTeXtTable does not fit page

Information and discussion about MikTeX distribution for Windows and the related proTeXt: Installing, updating, configuring
1111
Posts: 1
Joined: Fri Jul 31, 2020 5:55 pm

Table does not fit page

Postby 1111 » Fri Jul 31, 2020 6:01 pm

I am just learning LaTex. I used stata and got the following

{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}

\begin{tabular}{l*{3}{ccc}l}
\hline
\multicolumn{11}{l}{\textit{Panel A: }} \\
\hline\hline
&\multicolumn{3}{c}{Overall} &\multicolumn{3}{c}{Set Household} &\multicolumn{3}{c}{Non-set Household} & \multicolumn{1}{l}{T-test}\\
& count& mean& sd& count& mean& sd& count& mean& sd &\\
\hline
Average Age of the household respondent & 5000& 44.7& 12.8& 3400& 44.4& 12.5& 1016& 44.9& 13.1& 0.511 \\
& & & & & & & & & & (0.87) \\
Percentage of Married & 4000& 0.86& 0.35& 345& 0.87& 0.34& 800& 0.85& 0.35& -0.014\\
& & & & & & & & & & (-0.88) \\
Number of family that are dependent in the income & 99& 0.83& 0.67& 94& 0.79& 0.70& 5000& 0.86& 0.65 & 0.070\sym{*} \\
& & & & & & & & & & (2.29) \\

\hline
\multicolumn{11}{l}{\textit{Panel B: }} \\
\hline\hline

\hline
\multicolumn{11}{l}{\textit{Panel C: }} \\
\hline\hline

\hline\hline
\multicolumn{2}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\multicolumn{2}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
\end{tabular}
}

I edited the table and added Panel B and C later on as I generated new tables via stata. I am suing the following tex file to create my document as I have several tables

\documentclass[a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{paralist}
\usepackage{verbatim}
\usepackage{amssymb}
\usepackage{amsmath}

\usepackage{setspace}
\onehalfspacing
\usepackage[parfill]{parskip}

%--------------------------------------- Document --------------------------------------%

\title{\huge{}}
\author{}
\date{}

\begin{document}
\maketitle
\section*{Introduction}


\begin{table}[h]
\centering
\caption{ }
\input{d.tex}
\end{table}

\begin{table}[h]
\centering
\caption{}
\input{m.tex}
\end{table}

\end{document}

I have tried the following codes

1st
\begin{tabular}{ |p{3cm}||p{3cm}|p{3cm}|p{3cm}| |p{3cm}||p{3cm}|p{3cm}|p{3cm}| |p{3cm}||p{3cm}|}
2nd
\begin{tabular}{|l*{3}{ccc}l|}
3rd
\\resizebox{\textwidth}{p{3cm}}{\begin{tabular}{l*{3}{ccc}l}
4th
\begin{tabular}{\linewidth}{l*{3}{ccc}l}

but i got error and/or it did not solve my issue and the table still spilled out of the page. I hope someone here can help me resolve this issue i would be really thankful.

Bartman
Posts: 96
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Fri Jul 31, 2020 9:01 pm

Please try to create a Infominimal working example that the helpers can work with. You could e.g. replace the \input command with the content of the m.tex file.

An example is easier to read, if you make use of suitable BBCode.

One possibility would be to switch to landscape format so that the table does not protrude over the edges of the page layout.

If the table should remain in portrait format, then you shouldn't use \resizebox, but

  • replace the column type of the first column with p{<length>} to allow line breaks
    • In this case the number of columns of the \multicolumn commands in the footnotes of the table should be changed from 2 to 11.
  • decrease the font size for the table
  • change \tabcolsep to reduce the gap between columns

Also take a look at the packages booktabs, threeparttable and siunitx.


Return to “MiKTeX and proTeXt”

Who is online

Users browsing this forum: No registered users and 1 guest