Estoy intentando incluir esta tabla en una página que ya tiene texto. La tabla salta a la página siguiente y el texto que se suponía que debía estar en la página siguiente salta a la página donde debería estar la tabla.
- ¿Qué tengo que hacer?
\begin{table}[]
\centering
\caption{Regression results }
\begin{tabular}{llll}
\hline
\textbf{FDI} & \begin{tabular}[c]{@{}l@{}}OLS\\ (1)\end{tabular} & \begin{tabular}[c]{@{}l@{}}FE\\ (2)\end{tabular} & \begin{tabular}[c]{@{}l@{}}FGLS\\ (3)\end{tabular} \\ \hline
FDI.L1 & \begin{tabular}[c]{@{}l@{}}0.65*\\ (0.02)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.93**\\ (0.4)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.72*\\ (0.00)\end{tabular} \\
INFR & \begin{tabular}[c]{@{}l@{}}0.42***\\ (0.13)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.4072***\\ (0.1504)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.45*\\ (0.0)\end{tabular} \\
EXCH & \begin{tabular}[c]{@{}l@{}}0.40***\\ (0.17)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.49***\\ (0.15)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.45*\\ (0.36)\end{tabular} \\
MRKTS & \begin{tabular}[c]{@{}l@{}}1.51\\ (0.73)\end{tabular} & \begin{tabular}[c]{@{}l@{}}1.1\\ (0.7)\end{tabular} & \begin{tabular}[c]{@{}l@{}}1.1*\\ (0.08)\end{tabular} \\
MRKTS.L1 & \begin{tabular}[c]{@{}l@{}}0.85***\\ (0.26)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.55***\\ (0.24)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.7477*\\ (0.2261)\end{tabular} \\
UNMP & \begin{tabular}[c]{@{}l@{}}-0.0236\\ (0.09)\end{tabular} & \begin{tabular}[c]{@{}l@{}}-0.06\\ (0.07)\end{tabular} & \begin{tabular}[c]{@{}l@{}}-0.04\\ (0.00)\end{tabular} \\
NEWS & \begin{tabular}[c]{@{}l@{}}0.56***\\ (0.25)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.56***\\ (0.29)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.58*\\ (0.28)\end{tabular} \\
NEGT & \begin{tabular}[c]{@{}l@{}}0.23***\\ (0.02)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.23***\\ (0.7)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.31**\\ (0.17)\end{tabular} \\
CANDC & \begin{tabular}[c]{@{}l@{}}0.02\\ (0.08)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.02\\ (0.00)\end{tabular} & \begin{tabular}[c]{@{}l@{}}0.01\\ (0.17)\end{tabular} \\
Country 2 & \begin{tabular}[c]{@{}l@{}}-0.10\\ (0.13)\end{tabular} & - & \begin{tabular}[c]{@{}l@{}}-0.24\\ (0.17)\end{tabular} \\
Country 3 & \begin{tabular}[c]{@{}l@{}}0.07\\ (0.33)\end{tabular} & - & \begin{tabular}[c]{@{}l@{}}-0.18\\ (0.26)\end{tabular} \\
Country 4 & \begin{tabular}[c]{@{}l@{}}1.60***\\ (0.69)\end{tabular} & - & \begin{tabular}[c]{@{}l@{}}1.56**\\ (0.67)\end{tabular} \\
\end{tabular}
\end{table}
Respuesta1
En lugar de dedicar tiempo a intentar colocar la tabla en la página actual, haría un mayor esfuerzo para hacer que la tabla sea más legible y visualmente atractiva para los lectores. Por ejemplo, cargue el dcolumn
paquete y alinee todos los números en sus respectivos marcadores decimales. Mientras lo hace, aproveche la oportunidad para simplificar el código.drásticamente, digamos en la línea que se muestra en el siguiente ejemplo, que contiene solo 1 tabular
entorno en lugar de 40 [!!].
\documentclass{article}
\usepackage{booktabs,dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{table}[h!] % place table on current page, if at all possible
\centering
\caption{Regression results}
\begin{tabular}{@{} >{\scshape}l *{3}{d{2.5}} @{}}
\addlinespace
\toprule
FDI & \mc{OLS} & \mc{FE} & \mc{FGLS} \\
& \mc{(1)} & \mc{(2)} & \mc{(3)} \\
\midrule
fdi.l1 & 0.65^{*} & 0.93^{**} & 0.72^{*} \\
& (0.02) & (0.4) & (0.00) \\
infr & 0.42^{***} & 0.4072^{***}& 0.45^{*} \\
& (0.13) & (0.1504) & (0.0) \\
exch & 0.40^{***} & 0.49^{***} & 0.45^{*} \\
& (0.17) & (0.15) & (0.36) \\
mrkts & 1.51 & 1.1 & 1.1^{*} \\
& (0.73) & (0.7) & (0.08) \\
mrkts.l1& 0.85^{***} & 0.55^{***} & 0.7477^{*} \\
& (0.26) & (0.24) & (0.2261) \\
unmp & -0.0236 & -0.06 & -0.04 \\
& (0.09) & (0.07) & (0.00) \\
news & 0.56^{***} & 0.56^{***} & 0.58^{*} \\
& (0.25) & (0.29) & (0.28) \\
negt & 0.23^{***} & 0.23^{***} & 0.31^{**} \\
& (0.02) & (0.7) & (0.17) \\
candc & 0.02 & 0.02 & 0.01 \\
& (0.08) & (0.00) & (0.17) \\
country 2 &-0.10 & \mc{--} & -0.24 \\
& (0.13) & & (0.17) \\
country 3 & 0.07 & \mc{--} & -0.18 \\
& (0.33) & & (0.26) \\
country 4 & 1.60^{***} & \mc{--}& 1.56^{**} \\
& (0.69) & & (0.67) \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Respuesta2
Qué pasa longtable
? Comenzará donde le gustaría tener la tabla, pero su final estará en la página siguiente, por ejemplo así:
MWE a continuación se basa enmicoBuen pulido de tu código:
\documentclass{article}
\usepackage{booktabs, dcolumn, longtable}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\usepackage{lipsum}
\begin{document}
\lipsum[1-3]
\begin{longtable}{@{} >{\scshape}l *{3}{d{2.5}} @{}}
\caption{Regression results\newline} \\
\endfirsthead
\caption{Regression results (cont.)} \\
\toprule
\endhead
\midrule[0.6pt]
\multicolumn{4}{>{\footnotesize}r}{continue on the next page}
\endfoot
\endlastfoot
\toprule
FDI & \mc{OLS} & \mc{FE} & \mc{FGLS} \\
& \mc{(1)} & \mc{(2)} & \mc{(3)} \\
\midrule
fdi.l1 & 0.65^{*} & 0.93^{**} & 0.72^{*} \\
& (0.02) & (0.4) & (0.00) \\
infr & 0.42^{***} & 0.4072^{***}& 0.45^{*} \\
& (0.13) & (0.1504) & (0.0) \\
exch & 0.40^{***} & 0.49^{***} & 0.45^{*} \\
& (0.17) & (0.15) & (0.36) \\
mrkts & 1.51 & 1.1 & 1.1^{*} \\
& (0.73) & (0.7) & (0.08) \\
mrkts.l1& 0.85^{***} & 0.55^{***} & 0.7477^{*} \\
& (0.26) & (0.24) & (0.2261) \\
unmp & -0.0236 & -0.06 & -0.04 \\
& (0.09) & (0.07) & (0.00) \\
news & 0.56^{***} & 0.56^{***} & 0.58^{*} \\
& (0.25) & (0.29) & (0.28) \\
negt & 0.23^{***} & 0.23^{***} & 0.31^{**} \\
& (0.02) & (0.7) & (0.17) \\
candc & 0.02 & 0.02 & 0.01 \\
& (0.08) & (0.00) & (0.17) \\
country 2 &-0.10 & \mc{--} & -0.24 \\
& (0.13) & & (0.17) \\
country 3 & 0.07 & \mc{--} & -0.18 \\
& (0.33) & & (0.26) \\
country 4 & 1.60^{***} & \mc{--}& 1.56^{**} \\
& (0.69) & & (0.67) \\
\bottomrule
\end{longtable}
\lipsum
\end{document}