2

This is my latex code:

\begin{center}
\begin{table}[t]%
\centering
\caption{Results \label{data}}%
\begin{tabular*}{450pt}{@{\extracolsep\fill}lcccccccc@{\extracolsep\fill}}
\toprule
& \multicolumn{3}{c}{1data} && \multicolumn{3}{c}{2data} \\
M1 & M2 & M3 & M4 &&  M5 & M6 & M7 \\
\midrule
mean & 0.000  & &  && 0.0000  & &  \\
\bottomrule
\end{tabular*}
\end{table}
\end{center}

In line citation, I use:

As in Table \ref{data}, the results...

Then, I got "As in Table 1 , the results..." How to decrease gap between 1 and comma?

  • Welcome to TeX.SE. There seem to be two spacing issues: First, the excessive amount of space above and below the table environment; that's caused by the unnecessary use of a center environment to encase the table environment. As to your second question, about the cause of a gap between 1 and the comma: I'm afraid I'm unable to reproduce the issue on the basis of the code you've provided. Please provide compilable code that reproduces the issue you're trying to fix. – Mico Jul 10 '18 at 9:55
  • 2
    Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – user36296 Jul 21 '18 at 14:27
  • 1
    If one of the answers below answered your question, please consider accepting it (see tex.stackexchange.com/help/someone-answers). If the answer did not solve your question, you may want to leave a comment explaining why and/or edit your question to add additional detail that could help other people to help you. – moewe Sep 22 '18 at 17:08
2

You asked,

How to fix gap between text and table?

Answer: Omit the \begin{center} and \end{center} directives, as they are directly responsible for the excessive amount of whitespace between the running text and the table.

0

Prior advise

To make it more easy to reproduce your document situation, please provide a fully copy-pastable minimum work example (MWE) for further questions to be asked. As an example

  1. I had to guess which tabular package you have used to format your table and
  2. had to add some dummy text (in this case I used lipsum)

to actually see your problem(s).

Remove white-space

You can get rid of the (unwanted additional) white-space before and after a float by omitting the environment \begin{center} ... \end{center}. For centered floats place the command \centering within the float you want to be centered (as you already did).

Side notes

  • Guessing that you wanted the table to fit the line width I recommend the use of the command \linewidth as the width parameter instead of a fixed value 450pt as it will automatically fit your text width regardless of your document's actual size (especially useful if you experiment with the document width later on)
  • Whilst using the placement flag "here" h you might want to consider putting a \noindent after your float to prevent latex to put an indent in front of the succeeding line. This is unnecessary for the other placement flags.

Demonstration

\documentclass{scrartcl}
\usepackage{lipsum}
\usepackage{booktabs}

\begin{document}
\section{Table here}
\lipsum[1]
\begin{table}[h]%
\centering
\caption{Results \label{data1}}%
\begin{tabular*}{\linewidth}{@{\extracolsep\fill}lcccccccc@{\extracolsep\fill}}
\toprule
& \multicolumn{3}{c}{1data} && \multicolumn{3}{c}{2data} \\
M1 & M2 & M3 & M4 &&  M5 & M6 & M7 \\
\midrule
mean & 0.000  & &  && 0.0000  & &  \\
\bottomrule
\end{tabular*}
\end{table}
\noindent %if you prefer to not have an indent after the table
\lipsum[1-2]

\subsection{Table top}
\lipsum[1-2]
\begin{table}[t]%
\centering
\caption{Results \label{data2}}%
\begin{tabular*}{\linewidth}{@{\extracolsep\fill}lcccccccc@{\extracolsep\fill}}
\toprule
& \multicolumn{3}{c}{1data} && \multicolumn{3}{c}{2data} \\
M1 & M2 & M3 & M4 &&  M5 & M6 & M7 \\
\midrule
mean & 0.000  & &  && 0.0000  & &  \\
\bottomrule
\end{tabular*}
\end{table}
\lipsum[1]

\newpage
\subsection{Table bottom}
\lipsum[1-3]
\begin{table}[b]%
\centering
\caption{Results \label{data3}}%
\begin{tabular*}{\linewidth}{@{\extracolsep\fill}lcccccccc@{\extracolsep\fill}}
\toprule
& \multicolumn{3}{c}{1data} && \multicolumn{3}{c}{2data} \\
M1 & M2 & M3 & M4 &&  M5 & M6 & M7 \\
\midrule
mean & 0.000  & &  && 0.0000  & &  \\
\bottomrule
\end{tabular*}
\end{table}
\lipsum[1]

\subsection{Table page}
\lipsum[1-2]
\begin{table}[p]%
\centering
\caption{Results \label{data4}}%
\begin{tabular*}{\linewidth}{@{\extracolsep\fill}lcccccccc@{\extracolsep\fill}}
\toprule
& \multicolumn{3}{c}{1data} && \multicolumn{3}{c}{2data} \\
M1 & M2 & M3 & M4 &&  M5 & M6 & M7 \\
\midrule
mean & 0.000  & &  && 0.0000  & &  \\
\bottomrule
\end{tabular*}
\end{table}
\lipsum[1]

\end{document}

Here you can see all placements variants. Hope it helps.

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.