3

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!

  • 1
    Welcome to SE! Please make your code sniped as small document beginning with documentclass{...} and ending by end{document}, that it can be compiled. – Zarko Feb 14 '16 at 13:00
  • 3
    scalebox does not shrink the space (but scaling the table should be an absolute last resort, and even then don't do it:-0 – David Carlisle Feb 14 '16 at 13:04
2

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.5\baselineskip.

  • 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.5\baselineskip]{caption}
%% define a few struts
%% (from code by Claudio Beccari in TeX and TUG News, Vol. 2, 1993)
\newcommand\Tstrut{\rule{0pt}{2.9ex}}         % "top" strut
\newcommand\Bstrut{\rule[-1.2ex]{0pt}{0pt}}   % "bottom" strut
\newcommand\TBstrut{\Tstrut\Bstrut}           % "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^A\TBstrut & d^B  & d^C  & l^{A}_{12} & l^C_{12} & h^A & h^C \\
\hline
-0.4434\TBstrut & 0.3455 & 0.7798 & 0.1023 & 0.1523 & 0.04 & 0.023 \\
\hline
\end{array}$
\end{table}
\end{document}
1

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 geometry\strut}
        \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 geometry\strut}
        \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 geometry\strut}
        \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

  • Hi, I've tried your code and there is no space between the caption and the table – Toan Feb 14 '16 at 13:57
  • If your want more space, you could add a \medskip after the \caption. – Christian Lindig Feb 14 '16 at 14:01
1

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 geometry\strut}\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

0

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.

0

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}{
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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