ptrcao wrote:[…] Usually I find the table environment helps to control the line spacing before and after the table, so for aesthetic reasons, but I guess this could easily be achieved manually? […]
Additional vertical space is not necessary here. The
leftbar environment already inserts some space (see code below).
ptrcao wrote:[…] Elsewhere in the document I'm afraid captions would be used, so it'd still be nice to find a way to make it work […]
Take a look at the
caption package and its
\captionof command (see code sample below).
Code: Select all
\documentclass[12pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{booktabs,framed}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{leftbar}
\captionof{table}{Table caption}
\centerline{%
\begin{tabular}{lccc}\toprule
& black & red & yellow\\ \midrule
expected \% & 70 & 26 & 1 \\
observed \% & 64 & 33 & 3 \\ \bottomrule
\end{tabular}
}
\bigskip
As the cross-tabulation above shows, black was underrepresented by 6\% in the ecologist's captive population, whilst both of red and yellow were overrepresented by 7\% and 2\% respectively, relative to the wild population.
\end{leftbar}
\blindtext
\end{document}
Although not recommendable, the
\centerline command was exceptionally used here to center the table (see
l2tabu). Other approaches didn't work properly for me.
As always, the
blindtext package is only for creating dummy text thus not part of the solution.