并排表格

并排表格

我正在尝试将两个表格结构并排放置,并在中间放置一个 tikz 图形,但似乎无法使用 minipage 结构获得我想要的结果。这是我的代码

\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{picture}
\usepackage{caption}
\usepackage{tikz-rdf}
\usepackage{tikz}
\usepackage{tkz-graph}
\usepackage{tkz-berge}

\usetikzlibrary{shapes,shapes.callouts,,decorations.text,shapes.misc,decorations.pathmorphing,shapes.geometric,backgrounds,fit,positioning,arrows}

\begin{document}

\begin{figure}[t]
\begin{minipage}[b]{.30\textwidth}
  \centering
  \scalebox{.6}{
      \begin{tabular}{| p{1.5cm} | c | c | c |} \hline
        title & nationality & locatedIn & salary \\ 
        ?t & ?n & ?p & ?s \\ \hline
        Professor  &  American & USA &  \$100,000 \\ \hline
        Professor  &  American & China &  \$100,000 \\ \hline
        Assistant Professor  &  Canadian & China &  \$45,000 \\ \hline
        Assistant Professor  &  Canadian & China &  \$45,000 \\ \hline
        Assistant Professor  &  Canadian & China &  \$45,000 \\ \hline
      \end{tabular}
  }
\end{minipage}
%
\begin{minipage}{.2\textwidth}
              \begin{tikzpicture}
                \draw[
                     -triangle 90,
                        line width=1mm,
                        postaction={draw, line width=0.3cm, shorten >=0.3cm, -}
                ] (0,0) -- (1,0);
           \end{tikzpicture}


\end{minipage}
        %
 \begin{minipage}[b]{.30\textwidth}%{80mm}
        \centering
                 \scalebox{.6}{
              \begin{tabular}{| p{1.5cm} | c | c | c |} \hline
                title & nationality & locatedIn & salary \\ 
                ?t & ?n & ?p & ?s \\ \hline
                Professor  &  American & USA &  \$100,000 \\ \hline
                Professor  &  American & China &  \$100,000 \\ \hline
                Assistant Professor  &  Canadian & China &  \$135,000 \\ \hline
              \end{tabular}
            }
        \end{minipage}
        \end{figure}
          \captionof{table}{Current and Mean B with a Reversed Polarity}

        \end{document}

我得到的输出如下。如能得到任何帮助,我将不胜感激。

在此处输入图片描述

答案1

矩阵!

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,positioning}
\begin{document}
\begin{table}
\centering%
\begin{tikzpicture}[scale=0.6,column 1/.style={nodes={text width=1.5cm}}]
\matrix[matrix of nodes,
            draw,
            %outer sep=2mm,
            %
            ] (firsttable) {
        title & nationality & locatedIn & salary \\ 
        ?t & ?n & ?p & ?s \\ \hline
        Professor  &  American & USA &  \$100,000 \\ \hline
        Professor  &  American & China &  \$100,000 \\ \hline
        Assistant Professor  &  Canadian & China &  \$45,000 \\ \hline
        Assistant Professor  &  Canadian & China &  \$45,000 \\ \hline
        Assistant Professor  &  Canadian & China &  \$45,000 \\ 
};

\matrix[matrix of nodes,
            draw,
            right = 2 cm of firsttable.south east,
                        anchor= south west,
            ] (secondtable) {
                title & nationality & locatedIn & salary \\ 
                ?t & ?n & ?p & ?s \\ \hline
                Professor  &  American & USA &  \$100,000 \\ \hline
                Professor  &  American & China &  \$100,000 \\ \hline
                Assistant Professor  &  Canadian & China &  \$135,000 \\
};
 \draw[
                     -triangle 90,
                        line width=1mm,
                        postaction={draw, line width=0.3cm, shorten >=0.3cm, -}
                ] ([xshift=3mm]firsttable.east |- secondtable.west) -- ([xshift=-3mm]secondtable.west);

\foreach \x in {1,2,3}{
\draw (firsttable.north west -| firsttable-1-\x.north east) |- (firsttable.south west -| firsttable-4-\x.north east);
}
\foreach \x in {1,2,3}{
\draw (secondtable.north west -| secondtable-1-\x.north east) |- (secondtable.south west -| secondtable-4-\x.north east);
}
\end{tikzpicture}
\caption{Current and Mean B with a Reversed Polarity}
\label{tikztable}
\end{table}
\end{document}

在此处输入图片描述

编辑:我重新定位了表格并绘制了垂直分隔符。但是强烈建议避免使用垂直分隔符,但这是另一回事,我对此了解不多,无法发表评论。

答案2

您正在使用两列,因此\linewidth小于一半\textwidth,但表格宽度加起来却大于该值,难道您不想根据\linewidth? 或者 来确定宽度,这\columnwidth可能更好。

答案3

如果你将它们全部包装在一起,minipage它们就会彼此相邻放置。你还应该figure*twocolumn文档中使用:

\begin{figure*}[t]
  \begin{minipage}{\textwidth}
      ...
  \end{minipage}
\end{figure*}

我添加了\usepackage{showframe},以便您可以看到边距在哪里并根据需要调整设置:

在此处输入图片描述

代码:

\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{picture}
\usepackage{caption}
%\usepackage{tikz-rdf}
\usepackage{tikz}
\usepackage{tkz-graph}
\usepackage{tkz-berge}

\usepackage{showframe}

\usetikzlibrary{shapes,shapes.callouts,,decorations.text,shapes.misc,decorations.pathmorphing,shapes.geometric,backgrounds,fit,positioning,arrows}

\begin{document}

\begin{figure*}[t]
\begin{minipage}{\textwidth}
\begin{minipage}[b]{.30\textwidth}
  \centering
  \scalebox{.6}{
      \begin{tabular}{| p{1.5cm} | c | c | c |} \hline
        title & nationality & locatedIn & salary \\ 
        ?t & ?n & ?p & ?s \\ \hline
        Professor  &  American & USA &  \$100,000 \\ \hline
        Professor  &  American & China &  \$100,000 \\ \hline
        Assistant Professor  &  Canadian & China &  \$45,000 \\ \hline
        Assistant Professor  &  Canadian & China &  \$45,000 \\ \hline
        Assistant Professor  &  Canadian & China &  \$45,000 \\ \hline
      \end{tabular}
  }
\end{minipage}
%
\begin{minipage}{.2\textwidth}
    \begin{tikzpicture}
                \draw[
                     -triangle 90,
                        line width=1mm,
                        postaction={draw, line width=0.3cm, shorten >=0.3cm, -}
                ] (0,0) -- (1,0);
    \end{tikzpicture}
\end{minipage}
%
\begin{minipage}[b]{.30\textwidth}%{80mm}
        \centering
        \scalebox{.6}{
              \begin{tabular}{| p{1.5cm} | c | c | c |} \hline
                title & nationality & locatedIn & salary \\ 
                ?t & ?n & ?p & ?s \\ \hline
                Professor  &  American & USA &  \$100,000 \\ \hline
                Professor  &  American & China &  \$100,000 \\ \hline
                Assistant Professor  &  Canadian & China &  \$135,000 \\ \hline
              \end{tabular}
        }
\end{minipage}
\captionof{table}{Current and Mean B with a Reversed Polarity}
\end{minipage}
\end{figure*}
\end{document}

答案4

%只需在命令后添加\end{minipage}

...
\end{minipage}%
%
\begin{minipage}{.2\textwidth}
...

在此处输入图片描述

相关内容