两个表格相互对齐

两个表格相互对齐

我希望两个表格居中,但底部表格与顶部表格对齐

处于中间

我不想这样

在此处输入图片描述

顶部仍应居中,底部应对齐

\begin{table}[!h]
\begin{center}
\caption{Survey Table}
\label{table4}
\begin{tabular}{|c|c|c|c|c|}
\hline
Ref. &     D2D      &     BS        & Interference &   QoS  \\
     & Interference & Interference  &   avoidance  &        \\
     &   reduction  &   reduction   &              &        \\
\hline
\cite{2}
& $\boxtimes$ 
& $\text{\rlap{$\checkmark$}}\square$ 
& $\boxtimes$ 
& $\boxtimes$ \\
 \hline
\cite{3}
& $\text{\rlap{$\checkmark$}}\square$
& $\text{\rlap{$\checkmark$}}\square$
& $\boxtimes$
& $\text{\rlap{$\checkmark$}}\square$ \\
\hline
\cite{5}
& $\text{\rlap{$\checkmark$}}\square$
& $\text{\rlap{$\checkmark$}}\square$
& $\boxtimes$
& $\text{\rlap{$\checkmark$}}\square$ \\
\hline
\cite{6}
&
&
& $\text{\rlap{$\checkmark$}}\square$
& $\text{\rlap{$\checkmark$}}\square$ \\
\hline
\end{tabular}

\\
\\


\begin{tabular}{|c|c|c|c|}
\hline
Ref. &   Self         &  Less     &   Controlled \\
     & organized     &  Spatial   &       by     \\
     &               & diversity  &              \\
\hline
\cite{2}
& $\text{\rlap{$\checkmark$}}\square$ 
& $\text{\rlap{$\checkmark$}}\square$ 
& D2D  \\
\hline
\cite{3}
& $\boxtimes$ 
& $\text{\rlap{$\checkmark$}}\square$ 
& D2D $\&$ BS \\
\hline
\cite{5}
& $\boxtimes$ 
& $\text{\rlap{$\checkmark$}}\square$ 
& BS \\
\hline
\cite{6}
& $\boxtimes$ & $\boxtimes$ 
& BS \\
\hline

\end{tabular}
\end{center}
\end{table}

答案1

这里,我只是将两个tabulars 堆叠在一起,左对齐,零间隙。请注意,我重新定义了\cite,因为 OP 没有提供引用数据。

\documentclass{article}
\usepackage{amsmath,amssymb,stackengine}
\def\cite#1{#1}
\begin{document}
\begin{table}[!h]
\begin{center}
\caption{Survey Table}
\label{table4}
\stackengine{0pt}{%
\begin{tabular}{|c|c|c|c|c|}
\hline
Ref. &     D2D      &     BS        & Interference &   QoS  \\
     & Interference & Interference  &   avoidance  &        \\
     &   reduction  &   reduction   &              &        \\
\hline
\cite{2}
& $\boxtimes$ 
& $\text{\rlap{$\checkmark$}}\square$ 
& $\boxtimes$ 
& $\boxtimes$ \\
 \hline
\cite{3}
& $\text{\rlap{$\checkmark$}}\square$
& $\text{\rlap{$\checkmark$}}\square$
& $\boxtimes$
& $\text{\rlap{$\checkmark$}}\square$ \\
\hline
\cite{5}
& $\text{\rlap{$\checkmark$}}\square$
& $\text{\rlap{$\checkmark$}}\square$
& $\boxtimes$
& $\text{\rlap{$\checkmark$}}\square$ \\
\hline
\cite{6}
&
&
& $\text{\rlap{$\checkmark$}}\square$
& $\text{\rlap{$\checkmark$}}\square$ \\
\hline
\end{tabular}%
}{%
\begin{tabular}{|c|c|c|c|}
\hline
Ref. &   Self         &  Less     &   Controlled \\
     & organized     &  Spatial   &       by     \\
     &               & diversity  &              \\
\hline
\cite{2}
& $\text{\rlap{$\checkmark$}}\square$ 
& $\text{\rlap{$\checkmark$}}\square$ 
& D2D  \\
\hline
\cite{3}
& $\boxtimes$ 
& $\text{\rlap{$\checkmark$}}\square$ 
& D2D $\&$ BS \\
\hline
\cite{5}
& $\boxtimes$ 
& $\text{\rlap{$\checkmark$}}\square$ 
& BS \\
\hline
\cite{6}
& $\boxtimes$ & $\boxtimes$ 
& BS \\
\hline
\end{tabular}%
}{U}{l}{F}{F}{S}
\end{center}
\end{table}
\end{document}

在此处输入图片描述

答案2

您可以\begin{tabular}{@{}l@{}}...\end{tabular}在这两个表格周围使用,但这会使粘贴它们变得有些困难。

我们varwidth可以做到这一点,将其设置\lineskip为规则厚度的负数。

请注意,我为这些框定义了两个个人命令:每次在几个地方多次使用某个特定构造时都执行此命令。打字稿将更加清晰,您可以随时更改定义,而无需浏览文档。

还要注意,center不应该在环境中使用table:更喜欢\centering声明。

\documentclass{article}
\usepackage{amsmath,amssymb,varwidth,caption}

\newcommand{\Crossed}{$\boxtimes$}
\newcommand{\Checked}{\makebox[0pt][l]{$\checkmark$}$\square$}

\begin{document}

\begin{table}[htp]
\centering

\caption{Survey Table}
\label{table4}

\begin{varwidth}{\columnwidth}
\setlength{\lineskip}{-0.4pt}\raggedright
\begin{tabular}{|c|c|c|c|c|}
\hline
Ref. &     D2D      &     BS        & Interference &   QoS  \\
     & Interference & Interference  &   avoidance  &        \\
     &   reduction  &   reduction   &              &        \\
\hline
\cite{2}
& \Crossed 
& \Checked 
& \Crossed 
& \Crossed \\
 \hline
\cite{3}
& \Checked
& \Checked
& \Crossed
& \Checked \\
\hline
\cite{5}
& \Checked
& \Checked
& \Crossed
& \Checked \\
\hline
\cite{6}
&
&
& \Checked
& \Checked \\
\hline
\end{tabular}

\begin{tabular}{|c|c|c|c|}
\hline
Ref. &   Self         &  Less     &   Controlled \\
     & organized     &  Spatial   &       by     \\
     &               & diversity  &              \\
\hline
\cite{2}
& \Checked 
& \Checked 
& D2D  \\
\hline
\cite{3}
& \Crossed 
& \Checked 
& D2D $\&$ BS \\
\hline
\cite{5}
& \Crossed 
& \Checked 
& BS \\
\hline
\cite{6}
& \Crossed & \Crossed 
& BS \\
\hline

\end{tabular}
\end{varwidth}

\end{table}

\end{document}

在此处输入图片描述

相关内容