一行三个子表

一行三个子表

我遇到了以下问题:a)第三个表格需要居中(图片下方)b)子表格 1 和 2 的标题需要居中

\documentclass{article}
\interdisplaylinepenalty=2500
\usepackage{tikz}
\usepackage[margin=1.5in]{geometry}  
\usepackage{caption}
\renewcommand{\tablename}{Table}
\captionsetup{labelsep = period} 
\usepackage{caption, subcaption, floatrow}
\begin{document}

\tikzset{ell/.style={ellipse,draw,minimum height=0.2cm,minimum width=0.2cm,inner sep=0.1cm}}

\begin{figure}[t]
%\begin{center}
\begin{tikzpicture}
\hspace{0.5cm}
\node[ell] (A)at (-14.5,1.5){$A$};
\node[ell] (o1)at (-15.5,0){$o_1$};
\node[ell] (B)at (-13.5,0) {$B$};
\node[ell] (o2)at (-14.25,-1.5) {$o_2$};
\node[ell] (o3)at (-12.75,-1.5) {$o_3$};
\draw [->] (A) to (o1);
\draw [->] (A) to (B);
\draw [->] (B) to (o2);
\draw [->] (B) to (o3);
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture}
\node[ell] (A_)at (-1,1.5){$A$};
\node[ell] (B_1)at (-2.5,0){$B$};
\node[ell] (B_2)at (0.5,0) {$B$};
\node[ell] (o_1)at (-3.25,-1.5) {$o_1$};
\node[ell] (o_2)at (-1.75,-1.5) {$o_2$};
\node[ell] (o_3)at (-0.25,-1.5) {$o_3$};
\node[ell] (o_4)at (1.25,-1.5) {$o_4$};

\draw [->] (A_) to (B_1);
\draw [->] (A_) to (B_2);
\draw [->] (B_1) to (o_1);
\draw [->] (B_1) to (o_2);
\draw [->] (B_2) to (o_3);
\draw [->] (B_2) to (o_4);

\end{tikzpicture}
\begin{tikzpicture}
\hspace{0.5cm}
\node[ell] (A__)at (-14.5,1.5){$A$};
\node[ell] (B__)at (-13.5,0) {$B$};
\node[ell] (o__1)at (-15.5,-1.5) {$o_1$};
\node[ell] (o__2)at (-12.75,-1.5) {$o_2$};

\draw [->] (A__) to (B__);
\draw [->] (B__) to (o__1);
\draw [->] (B__) to (o__2);
\draw [->] (A__) to (o__1);
\end{tikzpicture}

\vspace{1cm}

\hspace{1cm}
\begin{subtable}
\centering
\begin{tabular}{|c|c|}
\hline
$o_1$ & $o_1$ \\ \hline
$o_2$ & $o_3$ \\ \hline
\end{tabular}
\caption*{$g_1$}              
\end{subtable}
\hfill%
\begin{subtable}{0.5\linewidth}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
$o_1$ & $o_1$ & $o_2$ & $o_2$ \\ \hline
$o_3$ & $o_4$ & $o_3$ & $o_4$ \\
\hline
\end{tabular}
\caption*{$g_2$}
\end{subtable}
\hfill
\begin{subtable}
\centering
\begin{tabular}{|c|c|}
\hline
$o_1$ & $o_1$ \\ \hline
$o_1$ & $o_2$ \\ \hline
\end{tabular}
\caption*{$g_6$}
\end{subtable}
%\end{center}
\end{figure}

\end{document}

答案1

您的代码缺少三个subtable(better: subfigure) 环境中的两个环境所需的参数——所需宽度。提供一些看似合理的参数,并tabular用环境替换array环境,将得到以下屏幕截图。

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
%\interdisplaylinepenalty=2500
\usepackage{tikz}
\usepackage[margin=1.5in]{geometry}   
\usepackage{graphicx}
\usetikzlibrary{shapes,positioning}
%\renewcommand{\tablename}{Table} % why?
\usepackage[justification=centering,labelsep = period]{subcaption}

\begin{document}

\tikzset{ell/.style=
    {ellipse,draw,minimum height=0.2cm, minimum width=0.2cm, inner sep=0.1cm}}

\begin{figure}[t]
\begin{tikzpicture}
\hspace{0.25cm}
\node[ell] (A)at (-14.5,1.5){$A$};
\node[ell] (o1)at (-15.5,0){$o_1$};
\node[ell] (B)at (-13.5,0) {$B$};
\node[ell] (o2)at (-14.25,-1.5) {$o_2$};
\node[ell] (o3)at (-12.75,-1.5) {$o_3$};
\draw [->] (A) to (o1);
\draw [->] (A) to (B);
\draw [->] (B) to (o2);
\draw [->] (B) to (o3);
\end{tikzpicture}%
\hspace{1cm}
\begin{tikzpicture}
\node[ell] (A_)at (-1,1.5){$A$};
\node[ell] (B_1)at (-2.5,0){$B$};
\node[ell] (B_2)at (0.5,0) {$B$};
\node[ell] (o_1)at (-3.25,-1.5) {$o_1$};
\node[ell] (o_2)at (-1.75,-1.5) {$o_2$};
\node[ell] (o_3)at (-0.25,-1.5) {$o_3$};
\node[ell] (o_4)at (1.25,-1.5) {$o_4$};

\draw [->] (A_) to (B_1);
\draw [->] (A_) to (B_2);
\draw [->] (B_1) to (o_1);
\draw [->] (B_1) to (o_2);
\draw [->] (B_2) to (o_3);
\draw [->] (B_2) to (o_4);
\end{tikzpicture}
\hspace{0.25cm}
\begin{tikzpicture}
\node[ell] (A__)at (-14.5,1.5){$A$};
\node[ell] (B__)at (-13.5,0) {$B$};
\node[ell] (o__1)at (-15.5,-1.5) {$o_1$};
\node[ell] (o__2)at (-12.75,-1.5) {$o_2$};

\draw [->] (A__) to (B__);
\draw [->] (B__) to (o__1);
\draw [->] (B__) to (o__2);
\draw [->] (A__) to (o__1);
\end{tikzpicture}

\vspace{1cm}

\begin{subfigure}{0.3\linewidth}
\centering
$\begin{array}{|c|c|}
    \hline
    o_1 & o_1 \\ \hline
    o_2 & o_3 \\ \hline
\end{array}$
\caption*{$g_1$}              
\end{subfigure}%
\hfill
\begin{subfigure}{0.2\linewidth}
\centering
$\begin{array}{|c|c|c|c|}
    \hline
    o_1 & o_1 & o_2 & o_2 \\ \hline
    o_3 & o_4 & o_3 & o_4 \\ \hline
\end{array}$
\caption*{$g_2$}
\end{subfigure}%
\hfill
\begin{subfigure}{0.3\linewidth}
\centering
$\begin{array}{|c|c|}
    \hline
    o_1 & o_1 \\ \hline
    o_1 & o_2 \\ \hline
\end{array}$
\caption*{$g_6$}
\end{subfigure}

\end{figure}

\end{document}

相关内容