TransWikia.com

Space between caption and table in TeX

TeX - LaTeX Asked by Toan on April 17, 2021

I have this code

begin{table}[h]
caption{Numerical example geometry}
label{tab_numerical_geo}
begin{center}
scalebox{0.9}{
begin{tabular}{|c|c|c|c|c|c|c|}
hline
$d^A$  & $d^B$  & $d^C$  & $l^A_{12}$ & $l^C_{12}$ & $h^A$ & $h^C$ 
hline
-0.4434 & 0.3455 & 0.7798 & 0.1023 & 0.1523 & 0.04 & 0.023 
hline
end{tabular}
}
end{center}
end{table}

I’m using scalebox to reduce the size of the table, but it shrinks the space between the caption and the table. Without using it, there is a space, which is nice for my article.

Does anyone know how to reduce the size of the table while keeping that space?
I’ve tried with footnotesize instead of reducebox, but the result was the same.
Thanks!

7 Answers

In lack of information, why you actually use scalebox, I assume, that your document (i) has two columns, and that (ii) you will be willing to use mdwtab packages which enables to design nice tables ...

With this my assumptions the MWE below generate:

enter image description here

documentclass[twocolumn]{article}
    usepackage{caption}
    usepackage{mdwtab}

    usepackage[showframe]{geometry}
    usepackage{lipsum}   

begin{document}
lipsum[1]
begin{table}[h]
    footnotesize
    setlength{tabcolsep}{3.5pt}
caption{Numerical example geometry}
label{tab_numerical_geo}
centering
begin{tabular}{|*{7}{Mc|}}
hlx{hvv}
d^A  & d^B  & d^C  & l^A_{12} & l^C_{12} & h^A & h^C 
hlx{vhv}
-0.4434 & 0.3455 & 0.7798 & 0.1023 & 0.1523 & 0.04 & 0.023 
hlx{vh}
end{tabular}
end{table}
lipsum[2-5]
end{document}

option showframe in geometry package is used only to show page layout. In real-life, it had to be omitted.

Addendum: If you don't like to use mdwtab you can stick with classic tabular elements: replace hlx{...} with hline and column type Ml with >{$}c<{$}. For this column type you had to load package array. Of course, obtained table (to my taste) is not so beautiful.

Regarding caption: if you use package caption, you will obtain better spacing between caption and table without any manual adjustment.

Answered by Zarko on April 17, 2021

Some suggestions for typesetting the table are below. Without knowing your constraints it's difficult to be more concrete. To make sure the caption isn't getting too close to the top of the table, I've used a strut at the end of the caption.

    documentclass{article}
    usepackage{booktabs}
    begin{document}
    begin{table}
        caption{Numerical example geometrystrut}
        label{tab_numerical_geo}
        centering
        begin{tabular}{@{}ccccccc@{}}
        toprule
        $d^A$  & $d^B$  & $d^C$  & $l^A_{12}$ & $l^C_{12}$ & $h^A$ & $h^C$ 
        midrule
        $-0.4434$ & 0.3455 & 0.7798 & 0.1023 & 0.1523 & 0.04 & 0.023 
        bottomrule
        end{tabular}
    end{table}

    begin{table}
        caption{Numerical example geometrystrut}
        label{tab_numerical_geo2}
        catcode`!=active
        def!{phantom0}
        centering
        begin{tabular}{@{}lr@{}}
        toprule
        $d^A$       &$-0.4434$ 
        $d^B$       &0.3455    
        $d^C$       &0.7798  
        $l^A_{12}$  &0.1023       
        $l^C_{12}$  &0.1523    
        $h^A$       &0.04!!  
        $h^C$       &0.023!  
        bottomrule
        end{tabular}
    end{table}
    begin{table}
        caption{Numerical example geometrystrut}
        label{tab_numerical_geo3}
        catcode`!=active
        def!{phantom0}
        centering
        begin{tabular}{@{}lr@{qquad}lr@{}}
        toprule
        $d^A$       &$-0.4434$ &
        $d^B$       &0.3455    
        $d^C$       &0.7798   & 
        $l^A_{12}$  &0.1023       
        $l^C_{12}$  &0.1523   & 
        $h^A$       &0.04!!  
        $h^C$       &0.023!  
        bottomrule
        end{tabular}
    end{table}

    end{document}

enter image description here

enter image description here

enter image description here

Answered by Christian Lindig on April 17, 2021

Use package caption and resizebox:

documentclass[twocolumn]{article}
usepackage{caption}
usepackage{graphicx}
usepackage{booktabs}
usepackage{blindtext}
begin{document}
    blindtext
    begin{table}[!htb]
    caption{Numerical example geometrystrut}label{tab_numerical_geo}
    centering
    resizebox{linewidth}{!}{%
    begin{tabular}{@{}ccccccc@{}}toprule
    $d^A$  & $d^B$  & $d^C$  & $l^A_{12}$ & $l^C_{12}$ & $h^A$ & $h^C$    midrule
    $-0.4434$ & 0.3455 & 0.7798 & 0.1023 & 0.1523 & 0.04 & 0.023 bottomrule
    end{tabular}}
    end{table}

    blindtext
end{document}

enter image description here

Answered by user2478 on April 17, 2021

Some suggestions:

  • To create a bit more spacing between the caption and the tabular material, load the caption package and specify the desired value for the option skip; in the example below, I set skip=0.5baselineskip.

  • Don't use a center environment inside a table; instead, use the centering macro.

  • Since the material in the data row can, apparently, contain negative numbers, use an array environment instead of a tabular environment. Doing so will free you from having to type lots of $ symbols in the header row.

  • If you must use a smaller font size, don't use scalebox, as doing so will create very "spindly-looking" output. Instead, use small (for a 10% linear reduction of the font size) or footnotesize (for a 20% linear reduction).

  • For better spacing in the header and data rows, insert typographic struts.

enter image description here

documentclass{article}
usepackage[skip=0.5baselineskip]{caption}
%% define a few struts
%% (from code by Claudio Beccari in TeX and TUG News, Vol. 2, 1993)
newcommandTstrut{rule{0pt}{2.9ex}}         % "top" strut
newcommandBstrut{rule[-1.2ex]{0pt}{0pt}}   % "bottom" strut
newcommandTBstrut{TstrutBstrut}           % "top and bottom" strut

begin{document}

begin{table}
caption{Numerical example geometry}
label{tab_numerical_geo}
small % better than scalebox{0.9}{...}
centering
$begin{array}{|*{7}{c|}}
hline
d^ATBstrut & d^B  & d^C  & l^{A}_{12} & l^C_{12} & h^A & h^C 
hline
-0.4434TBstrut & 0.3455 & 0.7798 & 0.1023 & 0.1523 & 0.04 & 0.023 
hline
end{array}$
end{table}
end{document}

Answered by Mico on April 17, 2021

Try to add bigskip after the caption. It will add a blank line which will create a desired space.

documentclass{article} 
usepackage[utf8]{inputenc}
begin{document}
begin{table}[h]
caption{Numerical example geometry}
bigskip
label{tab_numerical_geo}
begin{center}
scalebox{0.9}{
...

Answered by Sabr3 on April 17, 2021

Came with the same issue, I tried the vspace{5mm} option. Worked easily well for me.

Answered by Adhisha Gammanpila on April 17, 2021

You can put begin{center} your table spec end{center} after your caption in the begin{table}.

Answered by Maryam Vahdat Pour on April 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP