2 つのテーブルがある表形式の環境で列間のスペースを削除するにはどうすればよいですか?

2 つのテーブルがある表形式の環境で列間のスペースを削除するにはどうすればよいですか?

以下の例では、右側の表のスペースを削除できません。

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

いくつかの例を見てきました。表形式環境で \pm 列間の余分なスペースを削除しますか?ただし、これらは異なる環境向けです。私が見逃している点について、どなたか教えていただけませんか? よろしくお願いします。

答え1

\multicolumn{4}{@{}c@{}}{...}最初のテーブルと\multicolumn{5}{@{}c@{}}{...}2 番目のテーブルに必要な情報です。

を使用するのではなく\extrarowheight、特定のテーブルの列間スペースを増やします。

中央揃えの方が適切と思われますが、それは好みの問題です。

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

ここに画像の説明を入力してください

重要な余談。
の定義に\mc重大なタイプミスがあります。 ではなく であるべき[7]です[1]

答え2

ドキュメントクラスは、 の値に対してllncsという非常に小さな値を設定します。これは、 のような環境で列間の空白の量を制御するパラメータです。他のほとんどのドキュメント クラスでは、 のデフォルト値はです。私の主な提案は、に対して (またはそれ以上の)値を設定することです。1.4pt\tabcolseptabular\tabcolsep6pt5pt\tabcolsep

ディレクティブの最初の引数は\multicolumn3 ではなく、それぞれ 4 と 5 であることに注意してください。なぜでしょうか? ヘッダーをすべての列にまたがらせたいのではないですか? また、おそらくどちらの側にも空白のパディングは必要ないため、 2 番目の引数はcではなく である必要があります。@{}c@{}

最後に、パッケージの線描画マクロを使用しているためbooktabs、 のデフォルト値を変更する必要はありません\extrarowheight

ここに画像の説明を入力してください

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

答え3

おそらく\multicolumn{3}{c}{Distance Matrix}\\そうすべきでしょう\multicolumn{5}{l}{Distance Matrix}\\。または、「時刻表」と「距離マトリックス」は、周囲のテーブルに単独で配置する必要があります。

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

ここに画像の説明を入力してください

関連情報