2

I could not find a proper way to reduce nicely the space between the table and the text:

enter image description here

Using \vspace{} doesn't help (it reduces the space between the text), as shown in the code below:

\documentclass[11pt,a4paper,twocolumn]{article}
\usepackage[utf8]{inputenc}
%\usepackage[margin=0cm]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb, amsthm}
\usepackage{graphicx}
\usepackage{lipsum}
%\usepackage{longtable}
\usepackage{booktabs}
\usepackage{xcolor,colortbl}
\definecolor{Gray}{gray}{0.85}
\newcolumntype{a}{>{\columncolor{Gray}}r}
\begin{document}

\lipsum

\begin{table*}[t!]
\scriptsize
\centering
\caption{Results.}
\label{tab:pairwise}
\setlength{\tabcolsep}{1.5mm}
\begin{tabular}{rarrarrarrar}
    \toprule
         time (s) &   value &   bound & time (s)     &   value &   bound  &     time (s) &     value &   bound &     time (s) &     value &   bound   \\ \midrule
     $   0.02$ & $ \mathbf{454.35}$ & $-\infty$ & $   0.78$ & $ 465.02$ & $-\infty$ & $  -$ &   $  -$ & $-$ &   $  14.75$ & $   1617196.00$ &       $-\infty$  \\
     $   0.03$ & $ 454.75$ & $ 294.89$ & $   0.15$ & $ 465.02$ & $ 136.28$ & $  -$ &   $  -$ & $-$ &   $   7.14$ & $   1614255.00$ & $301059.33$   \\ \cmidrule{1-1} 
     $  23.45$ & $ 480.27$ & $-\infty$ & $  64.00$ & $ 495.80$ & $-\infty$ & $   0.00$ & $1.05\times 10^{11}$ & $-\infty$ &  $2544.12$ & $   1664504.33$ &       $-\infty$ \\\cmidrule{1-1} 
    $  15.87$ & $ 483.41$ & $ 443.71$ & $  35.78$ & $ 605.14$ & $ 450.95$ & $   3.16$ & $1.05\times 10^{11}$ & $  16.35$ &  $-^*$ &         $-^*$       &         $-^*$\\
    $  55.32$ & $ 497.16$ & $ 411.94$ & $ 844.97$ & $ 468.97$ & $ 453.55$ & $   0.47$ &  $0.65\times 10^{11}$ & $  15.16$ &  $-^*$ &         $-^*$ &         $-^*$\\
    $1867.20$ & $ 468.88$ & $ 448.03$ & $2272.39$ & $ 479.54$ & $ 454.35$ & $   6.04$ &   $  \mathbf{21.22}$ & $  21.22$ &  $-^*$ &         $-^*$ &         $-^*$\\
    $  36.18$ & $ 455.25$ & $ 448.23$ & $ 111.74$ & $ 465.26$ & $ 455.43$ & $   2.33$ &  $0.10\times 10^{11}$ & $  14.47$ &  $2039.47$ & $   1664707.67$ & $   1583742.13$\\
    $   1.37$ & $ 490.48$ & $ 448.09$ & $  16.23$ & $ 500.09$ & $ 453.96$ & $   0.05$ &   $  64.19$ & $  15.22$ &  $ 421.20$ & $   \mathbf{1587961.67}$ & $   1584746.58$\\ \cmidrule{1-1} 
    $   1.92$ & $1399.51$ & $-\infty$ & $  11.62$ & $1178.91$ & $-\infty$ & $   0.08$ &   $ 127.01$ & $-\infty$ &  $3602.01$ & $  11408446.00$ &       $-\infty$\\ \cmidrule{1-1} 
    $   0.11$ & $ 485.88$ & $-\infty$ & $   0.29$ & $ 481.95$ & $-\infty$ & $   0.00$ &   $  84.86$ & $-\infty$ &  $  10.82$ & $   7022189.00$ &       $-\infty$\\
    $   1.10$ & $ 488.23$ & $-\infty$ & $   5.94$ & $ 489.82$ & $-\infty$ & $  20.10$ &   $  66.71$ & $-\infty$ &  $1989.12$ & $   6162418.00$ &       $-\infty$\\
    $   0.81$ & $ 489.80$ & $-\infty$ & $   5.19$ & $ 489.82$ & $-\infty$ & $  13.21$ &   $  58.52$ & $-\infty$ &  $1509.49$ & $   5209092.33$ &       $-\infty$\\ 
    $   9.84$ & $ \mathbf{454.35}$ & $-\infty$ & $  40.64$ & $ \mathbf{464.76}$ & $-\infty$ & $   0.31$ &   $  75.12$ & $-\infty$ &  $2377.66$ & $   1624106.00$ &       $-\infty$\\\bottomrule
\end{tabular}
\end{table*} \vspace*{-1.9cm}

\lipsum

\end{document}

Thank you in advance for your help!

  • 2
    Personally, I'd worry much more about the fact that the table is too wide to fit inside the textblock. – Mico Nov 15 '17 at 19:43
  • 2
    \vspace* should work. Better use How to change the spacing between figures/tables and text? – Bobyandbob Nov 15 '17 at 19:43
  • @Bobyandbob Have you tried compiling my example? – Khue Nov 15 '17 at 19:44
  • the vspace ( if you must use it) should be inside the table* not after it. – David Carlisle Nov 15 '17 at 19:48
  • @DavidCarlisle You're right, indeed. Thanks. – Khue Nov 15 '17 at 19:53
2

This does the trick:

\setlength{\dbltextfloatsep}{0.2cm}

Before posting the question I had tried:

\setlength{\textfloatsep}{0.2cm}

but it did not work. I realized that for two-column document \dbltextfloatsep should be used. Thanks to @Bobyandbob for pointing me to this answer.

And \vspace{} also works, if placed inside the table* environment, as pointed out by @DavidCarlisle (thanks!).

| improve this answer | |
2

The parameter \dbltextfloatsep is a "rubber" (i.e., stretchable and shrinkable) length, and its default value is 20pt plus 2pt minus 4pt. If that's too much for your taste, try

\setlength\dbltextfloatsep{0.75\baselineskip}

In addition, since your table -- except for the header row, consists entirely of math material, you should give serious thought to using an array environment instead of a tabular environment. That'll let you eliminate more than 300 [!!] $ symbols from the table, making the code much easier to parse. Do also replace all \cmidrule{1-1} directives with \addlinespace.

enter image description here

\documentclass[11pt,a4paper,twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{booktabs}

\usepackage[table]{xcolor}
\definecolor{Gray}{gray}{0.85}
\newcolumntype{a}{>{\columncolor{Gray}}r}

\usepackage{caption}
\captionsetup{skip=0.25\baselineskip}

\setlength\dbltextfloatsep{0.75\baselineskip}
\begin{document}

\lipsum[1]

\begin{table*}[t!]
\captionsetup{font=footnotesize}
\scriptsize
\centering
\caption{Results.} \label{tab:pairwise}
\setlength{\arraycolsep}{3.7pt}

$\begin{array}{@{} *{4}{rar} @{}}
\toprule
\text{time (s)} & \text{value} & \text{bound} & \text{time (s)} & \text{value} & \text{bound} &  
\text{time (s)} & \text{value} & \text{bound} & \text{time (s)} & \text{value} & \text{bound} \\ 
%\midrule
\addlinespace\addlinespace
        0.02 & \mathbf{454.35} & -\infty &    0.78 &  465.02 & -\infty &   - &     - & - & 14.75 &  1617196.00 &       -\infty  \\
        0.03 &          454.75 &  294.89 &    0.15 &  465.02 &  136.28 &   - &     - & - &  7.14 &  1614255.00 & 301059.33   \\ 
\addlinespace 
       23.45 &  480.27 & -\infty &   64.00 &  495.80 & -\infty &    0.00 & 1.05{\times} 10^{11} & -\infty &  2544.12 &    1664504.33 &       -\infty \\
\addlinespace 
      15.87 &  483.41 &  443.71 &   35.78 &  605.14 &  450.95 &    3.16 & 1.05{\times} 10^{11} &   16.35 &  -^* &         -^*       &         -^*\\
      55.32 &  497.16 &  411.94 &  844.97 &  468.97 &  453.55 &    0.47 &  0.65{\times} 10^{11} &   15.16 &  -^* &         -^* &         -^*\\
    1867.20 &  468.88 &  448.03 & 2272.39 &  479.54 &  454.35 &    6.04 &     \mathbf{21.22} &   21.22 &  -^* &         -^* &         -^*\\
      36.18 &  455.25 &  448.23 &  111.74 &  465.26 &  455.43 &    2.33 &  0.10{\times} 10^{11} &   14.47 &  2039.47 &    1664707.67 &    1583742.13\\
       1.37 &  490.48 &  448.09 &   16.23 &  500.09 &  453.96 &    0.05 &     64.19 &   15.22 &   421.20 &    \mathbf{1587961.67} &    1584746.58\\ 
\addlinespace 
       1.92 & 1399.51 & -\infty &   11.62 & 1178.91 & -\infty &    0.08 &    127.01 & -\infty &  3602.01 &   11408446.00 &  -\infty\\ 
\addlinespace 
       0.11 &  485.88 & -\infty &    0.29 &  481.95 & -\infty &    0.00 &     84.86 & -\infty &    10.82 &    7022189.00 &       -\infty\\
       1.10 &  488.23 & -\infty &    5.94 &  489.82 & -\infty &   20.10 &     66.71 & -\infty &  1989.12 &    6162418.00 &       -\infty\\
       0.81 &  489.80 & -\infty &    5.19 &  489.82 & -\infty &   13.21 &     58.52 & -\infty &  1509.49 &    5209092.33 &       -\infty\\ 
       9.84 &  \mathbf{454.35} & -\infty &   40.64 &  \mathbf{464.76} & -\infty &    0.31 &     75.12 & -\infty &  2377.66 &    1624106.00 &       -\infty\\
\bottomrule
\end{array}$

\end{table*} 

\lipsum[2-9]
\end{document}
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.