I am struggling to put the table (or figure) on the same page where I have specified my section (subsection). Does anyone of you know how to do this? Here is my MWE.
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{authblk}
\usepackage{amsmath,mathtools}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{float}
\usepackage{color}
\usepackage{geometry}\geometry{a4paper,left=25.4mm,right=25.4mm,top=25.4mm,bottom=25.4mm}
\usepackage{epsfig}
\usepackage{epstopdf}\epstopdfsetup{update}
\usepackage{booktabs}
\usepackage{caption}
\captionsetup[table]{aboveskip=0pt}\captionsetup[subfigure]{font=small, skip=0pt, labelformat=empty}
\usepackage{subcaption}
\usepackage{lscape}
\usepackage{setspace}
\usepackage{eurosym}
\usepackage[toc]{appendix}
%-------graphs begin at top of page--------------------------------%
\makeatletter
\setlength\@fptop{0pt}
%%\setlength\@fpsep{8pt plus 1fil}
\setlength\@fpsep{2pt}
\setlength\@fpbot{0pt}
\makeatother
%-------------------------------------------------------------------%
\begin{document}
\appendix
\section{Appendix}
\subsection{Table: Total WTP and Absolute WTP Contributions in total WTP}
%%-----begin tables---------------------------%%
\begin{landscape}
\setlength{\tabcolsep}{4.0ex}
\begin{table}[!ht]
\begin{center}
\begin{onehalfspace}
%\begin{footnotesize}
\caption{\textbf{Total WTP and Absolute WTP Contributions in WTP} \label{table1}}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{lcccccccccc}
\hline
\hline
\multicolumn{11}{c}{}\\[-2.8ex]
&\multicolumn{5}{c}{\textbf{WTP and Absolute Contributions to WTP (\euro/mnth) in 2007}}
&\multicolumn{5}{c}{\textbf{WTP and Absolute Contributions to WTP (\euro/mnth) in 2011}} \\
\multicolumn{11}{c}{}\\[-2.8ex]
\cmidrule(r){2-6} \cmidrule(r){7-11}
\multicolumn{11}{c}{}\\[-2.8ex]
&\multicolumn{1}{c}{$WTP$} &\multicolumn{1}{c}{${WTP^{a}}$}
&\multicolumn{1}{c}{${WTP^{h}}$}
&\multicolumn{1}{c}{${WTP^{n}}$}
&\multicolumn{1}{c}{${WTP^{u}}$}
&\multicolumn{1}{c}{$WTP$} &\multicolumn{1}{c}{${WTP^{a}}$}
&\multicolumn{1}{c}{${WTP^{h}}$}
&\multicolumn{1}{c}{${WTP^{n}}$}
&\multicolumn{1}{c}{${WTP^{u}}$} \\
\multicolumn{11}{c}{}\\[-2.8ex]
\hline
Austria & 524.60& 64.21& 351.90& 93.56& 14.92& 564.09& 59.08& 388.97& 93.95& 22.10\\
Belgium & 568.72& 76.23& 324.96& 136.36& 31.18& 583.87& 101.82& 365.13& 85.74& 31.17\\
Bulgaria & 170.71& 34.77& 75.01& 53.51& 7.41& 273.08& 65.19& 131.10& 50.87& 25.92\\
Cyprus & 487.98& 112.41& 205.27& 153.86& 16.44& 567.77& 126.43& 254.29& 152.58& 34.46\\
Czech Republic& 358.85& 44.43& 231.90& 77.53& 4.98& 401.78& 51.25& 273.73& 66.68& 10.11\\
Germany & 539.88& 52.30& 387.09& 76.31& 24.18& 637.33& 67.61& 449.12& 88.55& 32.06\\
Denmark & 441.69& 90.85& 292.38& 50.77& 7.68& 493.83& 66.35& 368.21& 33.11& 26.16\\
Estonia & 301.66& 81.67& 160.87& 54.61& 4.50& 370.63& 80.62& 238.73& 36.56& 14.72\\
Greece & 391.24& 73.38& 126.39& 166.19& 25.27& 341.10& 72.43& 140.36& 90.39& 37.93\\
Spain & 403.96& 46.62& 220.96& 111.58& 24.80& 446.12& 46.56& 259.03& 58.98& 81.54\\
Finland & 449.89& 73.10& 321.46& 49.85& 5.48& 531.48& 81.05& 403.96& 30.51& 15.95\\
France & 533.72& 88.15& 287.13& 134.61& 23.82& 585.92& 101.17& 366.29& 77.29& 41.17\\
Hungary & 291.90& 53.67& 152.57& 76.35& 9.32& 351.13& 56.47& 232.61& 45.15& 16.90\\
Italy & 690.68& 99.57& 346.04& 231.61& 13.45& 591.50& 74.25& 375.90& 119.01& 22.34\\
Lithuania & 280.98& 69.57& 138.70& 66.51& 6.19& 297.55& 49.85& 188.49& 36.05& 23.17\\
Luxembourg & 972.66& 148.27& 539.91& 260.70& 23.78& 932.12& 139.73& 673.81& 84.53& 34.05\\
Latvia & 298.61& 84.04& 147.19& 61.32& 6.06& 328.21& 88.26& 196.47& 24.64& 18.83\\
Netherlands & 493.10& 74.09& 332.48& 75.73& 10.80& 595.87& 88.74& 442.59& 45.62& 18.92\\
Poland & 316.78& 58.43& 147.72& 87.46& 23.17& 375.51& 63.00& 232.94& 53.32& 26.26\\
Portugal & 387.26& 52.06& 208.62& 103.69& 22.88& 371.92& 65.31& 236.98& 30.62& 39.01\\
Romania & 131.56& 33.36& 67.32& 29.35& 1.53& 191.48& 38.24& 119.72& 29.74& 3.78\\
Sweden & 402.96& 54.78& 276.07& 55.00& 17.11& 503.85& 76.78& 344.87& 50.95& 31.25\\
Slovenia & 544.01& 71.11& 365.14& 87.06& 20.70& 492.97& 55.61& 343.64& 46.81& 46.91\\
Slovakia & 292.05& 44.29& 178.43& 64.83& 4.51& 375.85& 46.93& 266.47& 44.51& 17.95\\
United Kingdom& 638.47& 122.23& 366.44& 126.98& 22.81& 566.39& 105.83& 350.07& 71.19& 39.31\\
\hline
\hline
\multicolumn{11}{p{29.0cm}}{Notes: Numbers denote mean values of (total) WTP and absolute contributions of non-income dimensions $d$, to total WTP ($WTP^{d}$) where $d\in (a, h, n, u)$. The results are weighted using the weights that do sum up to 1.\singlespacing} \\
\end{tabular}}
\end{onehalfspace}
\end{center}
\end{table}
\end{landscape}
%%-----end tables------------------------------%%
\end{document}
Best Answer
To place the section header, the subsection header, and the landscape-mode table all on one page, I suggest you do the following:
Since the table shouldn't float (in the LaTeX sense of the word), don't use a
table
environment.Instead, place the tabular material, along with the caption (generated by
\captionof{table}{...}
instead of\caption{...}
), in aminipage
environment. Set the width of theminipage
to something like 20cm -- wide enough so that all 11 columns of table fit without having to resort to tricks such as font size reductions, yet narrow enough so that theminipage
will fit on the page along with the section and subsection headers.Using a
\rotatebox
instruction, rotate theminipage
90 degrees counterclockwise to place it in landscape mode.For the tabular material, use a
tabularx
environment. Set the width of thetabularx
environment to\linewidth
-- which will be 20cm since that's the width of the surroundingminipage
.Align the numbers in columns 2 to 11 on their decimal markers using
S
column types (provided by thesiunitx
package), and use centered versions of theX
column type for the header cells.Don't overuse bold -- clarity is achieved much more effectively via good layout than by shouting in bold letters.