I have 2 tables, one above the other. At the moment I can't make any space between them in my report. The strange thing is I moved them in to a new blank document with all the same preamble and \vspace
worked. I don't really know what the problem is but it's frustrating that they are stuck together. My tables are within a subsection of a section. My preamble and table code are below:
\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}
Any help is appreciated.
Best Answer
table
is a floating environment, meaning that LaTeX can move it around, e.g. to avoid getting a large blank space at the end of page, if the table doesn't fit (for more details on how that works, see How to influence the position of float environments like figure and table in LaTeX?). For that reason, adding a\vspace
between twotable
environments doesn't really make sense, as the they can move away from that space.If the two tables should be placed just after one another, you can place both
tabular
s in the sametable
environment, and add the\vspace
between them, inside thetable
. See code below.Some other comments:
Be careful when using one-letter macro names, several of these are defined already, see Short names for macros
Note that the
\it
,\bf
, etc. font macros are deprecated because they do not use the new font selection scheme introduced with LaTeX2e. Please use{\itshape ..}
,{\bfseries ..}
or\textit{..}
,\textbf{..}
instead. See Does it matter if I use\textit
or\it
,\bfseries
or\bf
, etc. and Will two-letter font style commands (\bf
,\it
, …) ever be resurrected in LaTeX? for more information.Generally, I don't think you should use just
h!
as a float specifier. That limits where LaTeX can place the floats.If you ask egreg, he'll tell you that both
\left( ... \right)
and\ensuremath
are usually bad ideas. See "(" or "\left(" parentheses? (and linked questions) for some discussion about the former, and When not to use \ensuremath for math macro? about the latter.As the
table
environment (and all other environments, I think) form a group, it is not really necessary to use\bgroup
/\egroup
to limit the effect of the\arraystretch
I think.