我正在努力将表格(或图表)放在我指定部分(子部分)的同一页面上。你们有人知道怎么做吗?这是我的 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}
答案1
要将节标题、小节标题和横向模式表格全部放在同一页面上,我建议您执行以下操作:
由于表格不应该浮动(在 LaTeX 意义上),所以不要使用环境
table
。相反,将表格材料连同标题(由
\captionof{table}{...}
而不是生成\caption{...}
)一起放在minipage
环境中。将 的宽度设置minipage
为 20cm 左右——足够宽,这样表格的所有 11 列都可以放进去,而不必诉诸诸如字体大小减小之类的技巧,但又足够窄,这样 可以minipage
与节和子节标题一起放在页面上。使用
\rotatebox
指令,逆时针旋转minipage
90 度,使其处于横向模式。对于表格材料,使用
tabularx
环境。将环境的宽度设置tabularx
为\linewidth
-- 即 20cm,因为这是周围 的宽度minipage
。S
使用列类型(由包提供)将第 2 列至第 11 列中的数字与其小数点标记对齐siunitx
,并使用列类型的居中版本X
作为标题单元格。不要过度使用大胆的-- 通过良好的布局比通过用粗体字喊叫。
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{authblk}
\usepackage{mathtools}
\usepackage{amsthm,amsfonts,amssymb}
\usepackage{float,color}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage{siunitx,tabularx}
\sisetup{parse-numbers=false}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand\mc[1]{\multicolumn{1}{C}{#1}} % handy shortcut macro
\usepackage{epstopdf}
\epstopdfsetup{update}
\usepackage{booktabs,caption,subcaption}
\captionsetup[table]{aboveskip=0pt,font=bf}
\captionsetup[subfigure]{font=small, skip=0pt, labelformat=empty}
\usepackage{setspace}
\usepackage{eurosym}
\usepackage[toc]{appendix}
% --- floats on a floats-only page begin at top of page ---%
\makeatletter
\setlength\@fptop{0pt}
\makeatother
\begin{document}
\appendix
\section{Appendix}
\subsection{Table: Total WTP and Absolute WTP Contributions in total WTP}
\vspace*{1cm} % vertical offset
\noindent
\rotatebox{90}{% % rotate the minipage 90 degrees counter-clockwise
\begin{minipage}{20cm}
\captionof{table}{Total WTP and Absolute WTP Contributions in WTP} \label{table1}
\setlength\tabcolsep{0pt} % let LaTeX figure out widths of columns
\bigskip % whitespace between caption and tabular material
\begin{tabularx}{\linewidth}{ l *{10}{S[table-format=3.2]} }
\toprule
&\multicolumn{5}{>{\hsize=5\hsize}C}{WTP and Absolute Contributions to WTP (\euro/mnth) in 2007}
&\multicolumn{5}{>{\hsize=5\hsize}C}{WTP and Absolute Contributions to WTP (\euro/mnth) in 2011} \\
\cmidrule(lr){2-6} \cmidrule(l){7-11}
& \mc{$WTP$} & \mc{$WTP^{a}$} & \mc{$WTP^{h}$} & \mc{$WTP^{n}$} & \mc{$WTP^{u}$}
& \mc{$WTP$} & \mc{$WTP^{a}$} & \mc{$WTP^{h}$} & \mc{$WTP^{n}$} & \mc{$WTP^{u}$} \\
\midrule
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\\
\bottomrule
\addlinespace
\multicolumn{11}{p{\linewidth}}{\footnotesize 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.} \\
\end{tabularx}
\end{minipage}}
\end{document}