5

I am working on a long LaTeX document with several tables, which contain mainly text, or text and numbers. The tables are a \begin{table} ... \begin{tabular} environment. It is often difficult to see where the tables start and end on a page -- they are "mixing" in with the text too much and are disappearing, so it is difficult to easily locate "Table 1.1" and to navigate the document.

I found this solution to colour the entire table, but this only coloured the table itself, not the caption or footnotes under the table. I moved the \colorbox before the \begin{table} but this gave an error.

I tried inserting a \hline before the \end{table} but this also did not work.

How can I make the tables more prominent, without, obviously, making them garish? I thought a light shading under the entire table (caption, footnotes, etc.), or a bold line above and/or below the table?

SabreWolfy
  • 1,503

3 Answers3

7
\documentclass[11pt]{article}
\usepackage{xcolor,booktabs,caption}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{table}[htb]
\colorbox{blue!20}{%
\begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule}
\caption{default}
\centering
\begin{tabular}{@{} r|rrrrr @{}}\toprule
 \multicolumn{1}{c}{} & 1 & 2 & 3 & 4 & 5 \\\midrule
1 & 2.36 & 1.08 & -0.49 & -0.82 & -0.65 \\
  2 & -0.68 & -1.13 & -0.42 & -0.72 & 1.51 \\
  3 & -1.00 & 0.02 & -0.54 & 0.31 & 1.28 \\
  4 & -0.99 & -0.54 & 0.97 & -1.12 & 0.59 \\
  5 & -2.35 & -0.29 & -0.53 & 0.30 & -0.30 \\
  6 & -0.10 & 0.06 & -0.85 & 0.10 & -0.60 \\
  7 & 1.28 & -0.46 & 1.33 & -0.66 & -1.80 \\
  8 & 0.80 & 0.46 & 1.37 & 1.73 & 1.93 \\
  9 & -0.75 & 0.28 & 0.51 & 0.19 & 0.58 \\
  10 & -1.64 & -0.12 & -1.17 & -0.10 & -0.04 \\\bottomrule
\end{tabular}
\end{minipage}}
\end{table}
\lipsum[2]
\end{document}

enter image description here

If you need it for a lot of tabulars then define an own command for this.

Moriambar
  • 11,466
2

I tend to use sans serif fonts \sffamily in tables and figures in order to differentiate them better from the normal surrounding text. In addition I use a slightly smaller font \small. Here is an example:

\documentclass[parskip,paper=a4]{scrartcl}
\usepackage[left=20mm,right=20mm, top=20mm, bottom=20mm]{geometry}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{lmodern}

\usepackage{float}
\usepackage[demo]{graphicx}
\usepackage{booktabs}
\usepackage[%
    font={small,sf},
    labelfont=bf,
    format=hang,
]{caption}

\usepackage{blindtext}
\begin{document}

\section{Section Title}

\blindtext

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Figure caption font is different from the normal text font in order to get a better differentiation -- I like it that way.}
\end{figure}

\blindtext

\begin{table}[H]
\caption{Table caption font is different from the normal text font in order to get a better differentiation -- I like it that way.}
\centering
\small\sffamily
\begin{tabular}{llr}
\toprule
\multicolumn{2}{c}{Item} \\
\cmidrule(r){1-2}
Animal & Description & Price (\$) \\
\midrule
Gnat  & per gram & 13.65 \\
      & each     &  0.01 \\
Gnu   & stuffed  & 92.50 \\
Emu   & stuffed  & 33.33 \\
Armadillo & frozen & 8.99 \\
\bottomrule
\end{tabular}
\end{table}

\blindtext
\end{document}

Result:

enter image description here

1

This is with lines above and below the table:

\documentclass[11pt]{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{table}[htb]
\noindent\rule{\linewidth}{1.5pt}
\caption{default}
\centering
\begin{tabular}{r|rrrrr}
  \hline
 & 1 & 2 & 3 & 4 & 5 \\
  \hline
1 & 2.36 & 1.08 & -0.49 & -0.82 & -0.65 \\
  2 & -0.68 & -1.13 & -0.42 & -0.72 & 1.51 \\
  3 & -1.00 & 0.02 & -0.54 & 0.31 & 1.28 \\
  4 & -0.99 & -0.54 & 0.97 & -1.12 & 0.59 \\
  5 & -2.35 & -0.29 & -0.53 & 0.30 & -0.30 \\
  6 & -0.10 & 0.06 & -0.85 & 0.10 & -0.60 \\
  7 & 1.28 & -0.46 & 1.33 & -0.66 & -1.80 \\
  8 & 0.80 & 0.46 & 1.37 & 1.73 & 1.93 \\
  9 & -0.75 & 0.28 & 0.51 & 0.19 & 0.58 \\
  10 & -1.64 & -0.12 & -1.17 & -0.10 & -0.04 \\
   \hline
\end{tabular}
\noindent\rule{\linewidth}{1.5pt}
\end{table}
\lipsum[2]
\end{document}

enter image description here

Moriambar
  • 11,466