LaTeX forum ⇒ Graphics, Figures & TablesTable spilling off right of page

Information and discussion about graphics, figures & tables in LaTeX documents.
macro1995
Posts: 1
Joined: Mon Sep 19, 2022 11:20 pm

Table spilling off right of page

Postby macro1995 » Mon Sep 19, 2022 11:22 pm

Hi all, I have tried a bunch of things but can't get this table to stop spilling off the right of the page.

This is the code in my slideshow:
\begin{frame}{Summary Statistics}
    
\begin{table}[htpb]
\raggedright
\resizebox{2\textwidth}{!}{%
\input{Tabfigs/sumstats2}
}

\end{table}
\end{frame}


This is the code to make the table:

{
\renewcommand{\arraystretch}{.5}
	\hspace{10cm}
	%\centering
		\centering

			%\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
			%\begin{tabular}{ p{7cm} p{2cm} p{2cm} p{2cm} }
				
				\begin{tabular}{@{\extracolsep{50pt}}lrrrrrrrcccc@{}}
				
				\toprule
				\toprule
	
				  
				  
				 & \multicolumn{1}{c}{Mean: All} &  \multicolumn{1}{c}{SD: All} & \multicolumn{1}{c}{Mean: 16-19} &   \multicolumn{1}{c}{SD: 16-19} \\
				
				& \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)}& \multicolumn{1}{c}{(3)} & \multicolumn{1}{c}{(4)}\\
				\hline
			\\
				
			Panel A: Referral Level \\
			\cline{1-2} \\
		
	\# Parents in HH & \multicolumn{1}{c}{1.457} & \multicolumn{1}{c}{0.555} & \multicolumn{1}{c}{1.468}  & \multicolumn{1}{c}{0.561} \\
		 \\ 
		 \# Children in HH & \multicolumn{1}{c}{2.290} & \multicolumn{1}{c}{1.325} & \multicolumn{1}{c}{2.502} &  \multicolumn{1}{c}{1.428}\\
		 \\ 
		Father Present & \multicolumn{1}{c}{0.891} & \multicolumn{1}{c}{0.312} & \multicolumn{1}{c}{0.918} &  \multicolumn{1}{c}{0.274}\\
		 \\ 
		
		 Risk Score & \multicolumn{1}{c}{11.791} & \multicolumn{1}{c}{5.342} & \multicolumn{1}{c}{17.366} &  \multicolumn{1}{c}{1.136}\\
		 \\ 
		 Open Investigation & \multicolumn{1}{c}{0.463} & \multicolumn{1}{c}{0.497} & \multicolumn{1}{c}{0.617} &  \multicolumn{1}{c}{0.486}\\
		 \\ 
		Mandated Report & \multicolumn{1}{c}{0.712} & \multicolumn{1}{c}{0.453} & \multicolumn{1}{c}{0.711} &  \multicolumn{1}{c}{0.453}\\
		 \\ 
		 Reporter Type \\
		 \cline{1-1}\\
		School Report & \multicolumn{1}{c}{0.140} & \multicolumn{1}{c}{0.347} & \multicolumn{1}{c}{0.121} &  \multicolumn{1}{c}{0.326} \\
		 \\ 
		 Social Worker Report & \multicolumn{1}{c}{0.124} & \multicolumn{1}{c}{0.330} & \multicolumn{1}{c}{0.144}  & \multicolumn{1}{c}{0.351}\\
		 \\ 
		 Therapist Report & \multicolumn{1}{c}{0.119} & \multicolumn{1}{c}{0.323} & \multicolumn{1}{c}{0.104} &  \multicolumn{1}{c}{0.305}\\
		 \\ 
		Other Report & \multicolumn{1}{c}{0.617} & \multicolumn{1}{c}{0.486} & \multicolumn{1}{c}{0.631} & \multicolumn{1}{c}{0.482}\\
		 \\ 
		 Reason for investigation\\
		 \cline{1-1}\\
		 Physical Maltreatment & \multicolumn{1}{c}{0.177} & \multicolumn{1}{c}{0.382} & \multicolumn{1}{c}{0.148}  & \multicolumn{1}{c}{0.355}\\
		 \\ 
		 Physical Care & \multicolumn{1}{c}{0.173} & \multicolumn{1}{c}{0.378} & \multicolumn{1}{c}{0.172} &  \multicolumn{1}{c}{0.377}\\
		 \\ 
		 Exposure to Risk & \multicolumn{1}{c}{0.181} & \multicolumn{1}{c}{0.385} & \multicolumn{1}{c}{0.183} &  \multicolumn{1}{c}{0.387}\\
		  
		
		 \\
		 \textit{Observations} & \multicolumn{1}{c}{47,912} &  & \multicolumn{1}{c}{13,445}\\
		 \\ 
	
		
			Panel B: Child Level \\
			\cline{1-2} \\
		 
		 		Black & \multicolumn{1}{c}{0.503} & \multicolumn{1}{c}{0.500} & \multicolumn{1}{c}{0.579} & \multicolumn{1}{c}{0.414}\\
		 \\ 
		Male & \multicolumn{1}{c}{0.500} & \multicolumn{1}{c}{0.500} & \multicolumn{1}{c}{0.497} & \multicolumn{1}{c}{0.500}\\
		 \\ 
		Age & \multicolumn{1}{c}{8.513} & \multicolumn{1}{c}{5.149} & \multicolumn{1}{c}{8.849} & \multicolumn{1}{c}{5.420}\\
		 \\ 
		 Open Investigation & \multicolumn{1}{c}{0.501} & \multicolumn{1}{c}{0.500} & \multicolumn{1}{c}{0.638} & \multicolumn{1}{c}{0.481}\\
		 \\ 
		 Accepted for Services & \multicolumn{1}{c}{0.134} & \multicolumn{1}{c}{0.341} & \multicolumn{1}{c}{0.178} & \multicolumn{1}{c}{0.377}\\
		 \\ 
		Removed & \multicolumn{1}{c}{0.084} & \multicolumn{1}{c}{0.278} & \multicolumn{1}{c}{0.111} & \multicolumn{1}{c}{0.314}\\
		 \\ 
	
		 \textit{Observations} & \multicolumn{1}{c}{102,949} &  & \multicolumn{1}{c}{31,351}\\
		 \\ 
		
		
				\midrule
				\midrule
			\end{tabular}
			}
Attachments
example.png
example.png (36.34 KiB) Viewed 775 times

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
rais
Posts: 402
Joined: Sun Nov 16, 2014 8:51 pm

Table spilling off right of page

Postby rais » Thu Sep 22, 2022 10:00 pm

I'd start by stripping \hspace{..} and \extracolsep{..} from your `table code'. If that doesn't help, please provide a Infominimal working example and not just some code snippets.

KR
Rainer


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 11 guests