1

I am producing some tables (with no texts) to send the results to my coauthors. I am using the table environment to get automated table numbers and to contain the footnotes within table borders (below is an MWE). With lots of tables, I am trying to put section names above each set of tables. The problem I am facing is that the first table, does not matter how small it is, is moving to the next page. So the entire page below the section name remains empty. I was wondering if there is an easy way to solve that.

Kind regards, Syed

\singlespacing
\renewcommand{\mywide}{17cm}
\begin{table}[t]\centering
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\parbox{\mywide}{
\caption{DD estimate of school quality measures by gap with predicted property price, Aug09-Jan10}}
\begin{tabularx} {\mywide} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y @{}} \\
\midrule
Average score & estimate & SE &  p-val & Observations  \\
\midrule
Year 3, 2008 &     2.59&     5.39&     0.63&    1,047\\
Year 3, 2009 &     6.77&     5.10&     0.19&    1,050\\
\midrule
\end{tabularx}
\end{table}
\doublespacing
\normalsize
5
  • Welcome to TeX.SX! Your table floats away. In this case, the best strategy is to drop the table environment and use \captionof{table}{} instead of \caption. You need the caption package for this. However, there are some issues to improve here too!
    – user31729
    Aug 5 '15 at 12:15
  • Did you try using [!ht] for the placement?
    – Bernard
    Aug 5 '15 at 12:17
  • You could replace the bunch of 19(!!!!) Y - type column specifiers with *{19}Y ;-)
    – user31729
    Aug 5 '15 at 12:22
  • Thanks. \captionof{table}{} or !ht did not solve the problem. Column specifiers are working nicely.
    – Syed hasan
    Aug 5 '15 at 12:46
  • Your table is too wide by far, \centering has no effect then.
    – user31729
    Aug 5 '15 at 13:15
2

Not the real solution, but to show some possibilities. I've changed from tabularx to tabular however.

\documentclass{article}

\usepackage{setspace}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tabularx}

\usepackage{caption}
\newcommand{\mywide}{17cm}

\newcolumntype{Y}{>{\centering\arraybackslash}p{2cm}}

\begin{document}


\section{First}
\begingroup
\centering
\singlespacing
%\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} % What's this?
%\parbox{\mywide}{%
\captionof{table}[Short title]{DD estimate of school quality measures by gap with predicted property price, Aug09-Jan10}
%}%

\begin{tabular}{@{}l*{4}{Y}@{}} \\
\midrule
Average score & estimate & SE &  p-val & Observations  \\
\midrule
Year 3, 2008 &     2.59&     5.39&     0.63&    1,047\\
Year 3, 2009 &     6.77&     5.10&     0.19&    1,050\\
\midrule
\end{tabular}
%\end{tabularx}
\endgroup

\end{document}

enter image description here

6
  • Thanks @Christian Hupfer. I can run that too but whenever I include the same table with \include command, it does not work.
    – Syed hasan
    Aug 6 '15 at 6:53
  • @Syedhasan: Of course not, since \include automatically uses a \clearpage, i.e. inserts a new page effectively and then the content of the file. Use \input instead of \include
    – user31729
    Aug 6 '15 at 6:54
  • Thanks @Christian Hupfer. \input partially solved the problem.
    – Syed hasan
    Aug 6 '15 at 7:26
  • @Syedhasan: Partially?
    – user31729
    Aug 6 '15 at 7:27
  • Ok, fully. But in my case, tables are large and i still need to use \vspace to keep section headers at the same page with tables.
    – Syed hasan
    Aug 6 '15 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.