表格之间的垂直空间 vspace 不起作用

表格之间的垂直空间 vspace 不起作用

我有 2 个表格,一个在另一个上面。目前我无法在报告中为它们之间留出任何空间。奇怪的是,我将它们移到一个新的空白文档中,其中包含相同的序言,并且\vspace工作正常。我真的不知道问题是什么,但它们粘在一起真令人沮丧。我的表格位于一个部分的子部分内。我的序言和表格代码如下:

\documentclass[a4paper,12pt,reqno]{amsart}

\usepackage{tikz}        % only needed if you include TpX drawings
\usepackage{graphicx} % only needed if you include graphics files other than TpX
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{verbatim}
\usepackage{epstopdf}
\usepackage{color}
\usepackage{pdflscape}
\usepackage[section]{placeins}
\usepackage{amsfonts}
\usepackage{xfrac}
\usepackage{mathrsfs}
\usepackage{array}
\usepackage{subfig}
\usepackage{titletoc}
\usepackage{hyperref}


\theoremstyle{definition}
\newtheorem{example}{Example}
\numberwithin{figure}{section}
\numberwithin{equation}{section}
\numberwithin{table}{section}

\newcommand{\by}{\bf y} 
\newcommand{\bx}{\bf X} 
\newcommand{\T}{\text{T}} 


\newcommand{\bb}[1]{{\bf#1}}
\newcommand{\bo}[1]{\boldsymbol{#1}}
\newcommand{\E}[1]{{\mathbb E}\left[ #1 \right]}
\newcommand{\Var}[1]{{\mathbb {V}}\left(#1 \right)}

\newcommand{\ssc}[1]{\ensuremath{^{\textrm{#1}}}}

\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}

\setlength\extrarowheight{0pt}

\let\stdsection\section
\renewcommand\section{\newpage\stdsection}

\setlength\parindent{0pt}


\setcounter{tocdepth}{3}% to get subsubsections in toc

\let\oldtocsection=\tocsection

\let\oldtocsubsection=\tocsubsection

\let\oldtocsubsubsection=\tocsubsubsection

\renewcommand{\tocsection}[2]{\hspace{0em}\oldtocsection{#1}{#2}}
\renewcommand{\tocsubsection}[2]{\hspace{1em}\oldtocsubsection{#1}{#2}}
\renewcommand{\tocsubsubsection}[2]{\hspace{2em}\oldtocsubsubsection{#1}{#2}}


\begin{document}

\begin{table}[h!]
\caption{MCMC mixing results for the MH within Gibbs sampler} % title of Table
\centering % used for centering table
\bgroup
\def\arraystretch{2}
\begin{tabular}{c c c} % centered columns (4 columns)
     \bb{Response}: & \bb{ESS} (\%) & \bb{Acceptance rate} (\%) \\ \hline
     \bb{TST} & 100.0 & 52.90 \\
     \bb{WASO} & 99.90 & 56.68  \\
     \bb{N2} & 98.56 & 50.23 \\
     \bb{R} & 99.33 & 63.19  \\
\hline
\end{tabular}
\egroup
\label{mix} % is used to refer this table in the text
\end{table}
\vspace*{10mm}

\begin{table}[h!]
\caption{MCMC mixing results for the strongest and weakest models for benchmark $g$ for response \bb{TST}.} % title of Table
\centering % used for centering table
\bgroup
\def\arraystretch{2}
\begin{tabular}{c c c} % centered columns (4 columns)
     \bb{Model}: & \bb{ESS} (\%) & \bb{Acceptance rate} (\%) \\ \hline
     Strongest & 87.04 & 69.3 \\
     Weakest & 6.74 & 10.9 \\
\hline
\end{tabular}
\egroup
\label{mix2} % is used to refer this table in the text
\end{table}    

\end{document}

任何帮助都将受到赞赏。

答案1

table是一个浮动环境,这意味着 LaTeX 可以移动它,例如,如果表格不适合,可以避免在页面末尾出现较大的空白区域(有关其工作原理的详细信息,请参阅如何影响 LaTeX 中图形和表格等浮动环境的位置?)。因此,\vspace在两个table环境之间添加并没有实际意义,因为它们可以远离该空间。

如果要将两个表紧挨着放置,则可以将两个tabular表放在同一个环境中,然后在它们之间table添加。 请参阅下面的代码。\vspacetable

其他一些评论:

\documentclass[a4paper,12pt,reqno]{amsart}

\newcommand{\bb}[1]{\textbf{#1}}
\usepackage{lipsum}
\begin{document}

\begin{table}
\caption{MCMC mixing results for the MH within Gibbs sampler} % title of Table
\centering % used for centering table
\def\arraystretch{2}
\begin{tabular}{c c c} % centered columns (4 columns)
     \bb{Response}: & \bb{ESS} (\%) & \bb{Acceptance rate} (\%) \\ \hline
     \bb{TST} & 100.0 & 52.90 \\
     \bb{WASO} & 99.90 & 56.68  \\
     \bb{N2} & 98.56 & 50.23 \\
     \bb{R} & 99.33 & 63.19  \\
\hline
\end{tabular}

\vspace{10mm}

\caption{MCMC mixing results for the strongest and weakest models for benchmark $g$ for response \bb{TST}.} % title of Table
\begin{tabular}{c c c} % centered columns (4 columns)
     \bb{Model}: & \bb{ESS} (\%) & \bb{Acceptance rate} (\%) \\ \hline
     Strongest & 87.04 & 69.3 \\
     Weakest & 6.74 & 10.9 \\
\hline
\end{tabular}
\label{mix2} % is used to refer this table in the text
\end{table}

\end{document}

在此处输入图片描述

答案2

将两个表格放入 table环境。然后是你的\vspace作品。里面的一切table都是在本地的,不需要对其内容进行分组:

\documentclass[a4paper,12pt,reqno]{amsart}

\newcommand{\by}{\bf y} 
\newcommand{\bx}{\bf X} 
\newcommand{\T}{\text{T}} 
\newcommand{\bb}[1]{{\bf#1}}
\newcommand{\bo}[1]{\boldsymbol{#1}}
\newcommand{\E}[1]{{\mathbb E}\left[ #1 \right]}
\newcommand{\Var}[1]{{\mathbb {V}}\left(#1 \right)}
\newcommand{\ssc}[1]{\ensuremath{^{\textrm{#1}}}}

\begin{document}

\begin{table}[h!]
\caption{MCMC mixing results for the MH within Gibbs sampler} % title of Table
\label{mix} % is used to refer this table in the text
\centering % used for centering table
\def\arraystretch{2}
\begin{tabular}{c c c} % centered columns (4 columns)
     \bb{Response}: & \bb{ESS} (\%) & \bb{Acceptance rate} (\%) \\ \hline
     \bb{TST} & 100.0 & 52.90 \\
     \bb{WASO} & 99.90 & 56.68  \\
     \bb{N2} & 98.56 & 50.23 \\
     \bb{R} & 99.33 & 63.19  \\
\hline
\end{tabular}

\vspace*{10mm}
\caption{MCMC mixing results for the strongest and weakest models for benchmark $g$ for response \bb{TST}.} % title of Table
\label{mix2} % is used to refer this table in the text
\begin{tabular}{c c c} % centered columns (4 columns)
     \bb{Model}: & \bb{ESS} (\%) & \bb{Acceptance rate} (\%) \\ \hline
     Strongest & 87.04 & 69.3 \\
     Weakest & 6.74 & 10.9 \\
\hline
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

答案3

在第一个表之后使用\Floatbarrier(即,在您用 完成第一个表之后\end{table}),以便可以限制造成问题的浮动属性,然后\vspace在两个表之间添加。它对我有用。

相关内容