3

I'm not able to remove the space in the table on the right in the below example:

\documentclass[runningheads]{llncs}
%
\usepackage{subcaption}
\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{amsmath,array,booktabs}
%\UseTblrLibrary{amsmath, booktabs, counter}
\newtheorem{prop}{proposition}
\setlength\extrarowheight{5pt} % for a less cramped "look"
\newcommand\mc[7]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{table}[]
\caption{Timetable and distance matrix}
\label{tab:example_7}
\begin{tabular}{@{}llll@{}}
\multicolumn{3}{c}{Timetable}\\
\toprule
u & $t_i$  & $l_i$ & $s_i$\\ \midrule
0 & 0.0  & $90 $  & 0.0 \\
7 & 8.0& 1.15   & 1.0  \\
5 & 8.5& 8.75   & 7.0  \\
N & 0.0& $90 $  & 0.0  \\ \bottomrule
\end{tabular}
\qquad
\begin{tabular}{@{}lllll@{}}
\multicolumn{3}{c}{Distance Matrix}\\
\toprule
u & 0 & 7 & 5 & Y \\ \midrule
0 & 0 & 7 & 8 & 0 \\
7 & 1 & 0 & 5 & 1   \\
5 & 8 & 2 & 0 & 8   \\
N & 0 & 7 & 8 & 0   \\ \bottomrule
\end{tabular}
\end{table}
\end{document}

I've seen a few examples e.g. Remove extra space between \pm columns in tabular environment?, but they are for different environments. Can someone help me understand what I'm missing? Thanks.

3 Answers 3

3

You want \multicolumn{4}{@{}c@{}}{...} in the first table and \multicolumn{5}{@{}c@{}}{...} in the second one.

Rather than using \extrarowheight, I'd increase the intercolumn space for the particular tables.

Center alignment seems more appropriate, but it's a question of taste.

\documentclass[runningheads]{llncs}
\usepackage{booktabs}

\begin{document}

\begin{table}[htp]
\centering

\caption{Timetable and distance matrix}
\label{tab:example_7}

\setlength{\tabcolsep}{9pt}

\begin{tabular}{@{}cccc@{}}
\multicolumn{4}{@{}c@{}}{Timetable}\\
\toprule
u & $t_i$  & $l_i$ & $s_i$ \\
\midrule
0 & 0.0 &  90  & 0.0 \\
7 & 8.0 & 1.15 & 1.0 \\
5 & 8.5 & 8.75 & 7.0 \\
N & 0.0 &  90  & 0.0 \\
\bottomrule
\end{tabular}\qquad
\begin{tabular}{@{}ccccc@{}}
\multicolumn{5}{@{}c@{}}{Distance Matrix}\\
\toprule
u & 0 & 7 & 5 & Y \\
\midrule
0 & 0 & 7 & 8 & 0 \\
7 & 1 & 0 & 5 & 1 \\
5 & 8 & 2 & 0 & 8 \\
N & 0 & 7 & 8 & 0 \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

Important aside.
Your definition of \mc has a bad typo: it should not have [7], but [1].

2

The llncs document class sets an absurdly small value of just 1.4pt for the value of \tabcolsep; that's the parameter that governs the amount of intercolumn whitespace in tabular-like environment. In most other document classes, the default value of \tabcolsep is 6pt. My main suggestion is that you set a value of 5pt (or larger) for \tabcolsep.

Do note that the first argument of the \multicolumn directives shouldn't be 3 but, rather, 4 and 5, respectively. Why? You want the headers to span all columns, don't you? And, the second argument shouldn't be c but, rather, @{}c@{}, since you presumably don't want whitespace padding on either side.

Finally, since you're using the line-drawing macros of the booktabs package, there's no need to change the default value of \extrarowheight.

enter image description here

\documentclass{llncs}
\usepackage{booktabs} % for well-spaced horizontal rules

\begin{document}

\begin{table}
\caption{Timetable and distance matrix}
\label{tab:example_7}
\setlength\tabcolsep{5pt} % default: 1.4pt [!]
\centering

\begin{tabular}{@{}llll @{}}
\multicolumn{4}{@{}c@{}}{Timetable}\\
\toprule
u & $t_i$ & $l_i$ & $s_i$ \\ \midrule
0 & 0.0  & $90 $  & 0.0   \\
7 & 8.0  & 1.15   & 1.0   \\
5 & 8.5  & 8.75   & 7.0   \\
N & 0.0  & $90 $  & 0.0   \\ \bottomrule
\end{tabular}
\qquad
\begin{tabular}{@{} lllll @{}}
\multicolumn{5}{@{}c@{}}{Distance matrix}\\
\toprule
u & 0 & 7 & 5 & Y \\ \midrule
0 & 0 & 7 & 8 & 0 \\
7 & 1 & 0 & 5 & 1 \\
5 & 8 & 2 & 0 & 8 \\
N & 0 & 7 & 8 & 0 \\ \bottomrule
\end{tabular}
\end{table}

\end{document}
0

Probably \multicolumn{3}{c}{Distance Matrix}\\ should be \multicolumn{5}{l}{Distance Matrix}\\. Or "Timetable" and "Distance Matrix" should go in surrounding tables on their own.

\documentclass[runningheads]{llncs}
%
\usepackage{subcaption}
\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{amsmath,array,booktabs}
%\UseTblrLibrary{amsmath, booktabs, counter}
\newtheorem{prop}{proposition}
\setlength\extrarowheight{5pt} % for a less cramped "look"
\newcommand\mc[7]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{table}[htbp]%
\caption{Timetable and distance matrix}%
\label{tab:example_7}
\begin{tabular}{@{}llll@{}}
\multicolumn{4}{@{}l@{}}{Timetable}\\
\toprule
u & $t_i$  & $l_i$ & $s_i$\\ \midrule
0 & 0.0  & $90 $  & 0.0 \\
7 & 8.0& 1.15   & 1.0  \\
5 & 8.5& 8.75   & 7.0  \\
N & 0.0& $90 $  & 0.0  \\ \bottomrule
\end{tabular}
\qquad
\begin{tabular}{@{}lllll@{}}
\multicolumn{5}{@{}l@{}}{Distance Matrix}\\
\toprule
u & 0 & 7 & 5 & Y \\ \midrule
0 & 0 & 7 & 8 & 0 \\
7 & 1 & 0 & 5 & 1   \\
5 & 8 & 2 & 0 & 8   \\
N & 0 & 7 & 8 & 0   \\ \bottomrule
\end{tabular}
\end{table}

\newcommand\hp[2]{\vbox{\hphantloop#1\relax\hbox{#2}}}%
\newcommand\hphantloop[1]{%
  \ifx\relax#1\else\hbox{\hphantom{#1}}\expandafter\hphantloop\fi
}%

\begin{table}[htbp]%
\caption{Timetable and distance matrix}%
\label{tab:example_7-1}
\begin{tabular}{@{}c@{}}
%\begin{tabular}{@{}l@{}}
Timetable\\
\toprule
\begin{tabular}[t]{@{}llll@{}}
\hp{{u}{0}{7}{5}{N}}{u} & \hp{{$t_i$}{0.0}{8.0}{8.5}{0.0}}{$t_i$} & \hp{{$l_i$}{$90 $}{1.15}{8.75}{$90$}}{$l_i$} & \hp{{$s_i$}{0.0}{1.0}{7.0}{0.0}}{$s_i$}
\end{tabular}
\\ \midrule
\begin{tabular}[t]{@{}llll@{}}
\hp{{u}{0}{7}{5}{N}}{0} & \hp{{$t_i$}{0.0}{8.0}{8.5}{0.0}}{0.0}   & \hp{{$l_i$}{$90 $}{1.15}{8.75}{$90$}}{$90$}  & \hp{{$s_i$}{0.0}{1.0}{7.0}{0.0}}{0.0} \\
\hp{{u}{0}{7}{5}{N}}{7} & \hp{{$t_i$}{0.0}{8.0}{8.5}{0.0}}{8.0}   & \hp{{$l_i$}{$90 $}{1.15}{8.75}{$90$}}{1.15}  & \hp{{$s_i$}{0.0}{1.0}{7.0}{0.0}}{1.0} \\
\hp{{u}{0}{7}{5}{N}}{5} & \hp{{$t_i$}{0.0}{8.0}{8.5}{0.0}}{8.5}   & \hp{{$l_i$}{$90 $}{1.15}{8.75}{$90$}}{8.75}  & \hp{{$s_i$}{0.0}{1.0}{7.0}{0.0}}{7.0} \\
\hp{{u}{0}{7}{5}{N}}{N} & \hp{{$t_i$}{0.0}{8.0}{8.5}{0.0}}{0.0}   & \hp{{$l_i$}{$90 $}{1.15}{8.75}{$90$}}{$90$}  & \hp{{$s_i$}{0.0}{1.0}{7.0}{0.0}}{0.0}  
\end{tabular}
\\ \bottomrule
\end{tabular}
\qquad
\begin{tabular}{@{}c@{}}
Distance Matrix\\
\toprule
\begin{tabular}[t]{@{}lllll@{}}
\hp{{u}{0}{7}{5}{N}}{u} & \hp{{0}{0}{1}{8}{0}}{0} & \hp{{7}{7}{0}{2}{7}}{7} & \hp{{5}{8}{5}{0}{8}}{5} & \hp{{Y}{0}{1}{8}{0}}{Y}
\end{tabular}
\\ \midrule
\begin{tabular}[t]{@{}lllll@{}}
\hp{{u}{0}{7}{5}{N}}{0} & \hp{{0}{0}{1}{8}{0}}{0} & \hp{{7}{7}{0}{2}{7}}{7} & \hp{{5}{8}{5}{0}{8}}{8} & \hp{{Y}{0}{1}{8}{0}}{0} \\
\hp{{u}{0}{7}{5}{N}}{7} & \hp{{0}{0}{1}{8}{0}}{1} & \hp{{7}{7}{0}{2}{7}}{0} & \hp{{5}{8}{5}{0}{8}}{5} & \hp{{Y}{0}{1}{8}{0}}{1} \\
\hp{{u}{0}{7}{5}{N}}{5} & \hp{{0}{0}{1}{8}{0}}{8} & \hp{{7}{7}{0}{2}{7}}{2} & \hp{{5}{8}{5}{0}{8}}{0} & \hp{{Y}{0}{1}{8}{0}}{8} \\
\hp{{u}{0}{7}{5}{N}}{N} & \hp{{0}{0}{1}{8}{0}}{0} & \hp{{7}{7}{0}{2}{7}}{7} & \hp{{5}{8}{5}{0}{8}}{8} & \hp{{Y}{0}{1}{8}{0}}{0} 
\end{tabular}
\\ \bottomrule
\end{tabular}
\end{table}


\end{document}

enter image description here

2
  • 1
    You should also increase the value of \tabcolsep.
    – Mico
    Apr 20 at 9:43
  • @Mico Probably, but that's out of the scope of the question.I could also use tabularx and make the second table as wide as the phrase "Distance Matrix", but that was not asked.
    – user318657
    Apr 22 at 21:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .