Como remover o espaço entre colunas em ambiente tabular com duas tabelas?

Como remover o espaço entre colunas em ambiente tabular com duas tabelas?

Não consigo remover o espaço da tabela à direita no exemplo abaixo:

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

Eu vi alguns exemplos, por exemploRemover espaço extra entre colunas \pm em ambiente tabular?, mas são para ambientes diferentes. Alguém pode me ajudar a entender o que estou perdendo? Obrigado.

Responder1

Você quer \multicolumn{4}{@{}c@{}}{...}na primeira tabela e \multicolumn{5}{@{}c@{}}{...}na segunda.

Em vez de usar \extrarowheight, eu aumentaria o espaço entre colunas para tabelas específicas.

O alinhamento central parece mais apropriado, mas é uma questão de gosto.

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

insira a descrição da imagem aqui

Importante à parte.
Sua definição de \mctem um erro de digitação: não deveria ter [7], mas [1].

Responder2

A llncsclasse document define um valor absurdamente pequeno apenas 1.4ptpara o valor de \tabcolsep; esse é o parâmetro que controla a quantidade de espaços em branco entre colunas em tabularum ambiente semelhante a -. Na maioria das outras classes de documentos, o valor padrão \tabcolsepé 6pt. Minha principal sugestão é que você defina um valor igual 5pt(ou maior) para \tabcolsep.

Observe que o primeiro argumento das \multicolumndiretivas não deveria ser 3, mas sim 4 e 5, respectivamente. Por que? Você quer que os cabeçalhos abranjam todas as colunas, não é? E o segundo argumento não deveria ser c, mas sim, @{}c@{}, já que você provavelmente não deseja preenchimento de espaços em branco em nenhum dos lados.

Finalmente, como você está usando as macros de desenho de linha do booktabspacote, não há necessidade de alterar o valor padrão de \extrarowheight.

insira a descrição da imagem aqui

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

Responder3

Provavelmente \multicolumn{3}{c}{Distance Matrix}\\deveria ser \multicolumn{5}{l}{Distance Matrix}\\. Ou "Horário" e "Matriz de Distância" devem aparecer sozinhos nas tabelas vizinhas.

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

insira a descrição da imagem aqui

informação relacionada