我希望每个图形都具有相同的大小。我尝试使用 resizebox 来实现这一点,但我仍然认为还有很多需要改进的地方。第二件事是我想在图 (a) 和图 (b) 之间添加 \times 符号,在图 (b) 和图 (c) 之间添加 =。这可能吗?此外,我如何更改字幕的位置,以便 (a)、(b) 和 (c) 处于同一级别。这是我的代码:
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[export]{adjustbox}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{0.33\textwidth}
\centering
\resizebox{0.08\textwidth}{!}{%
\begin{tikzpicture}
\node (1) at (0,0) {$1$};
\node (2) at (0,4) {$2$};
\draw[red] (1)--(2);
\end{tikzpicture}}
\caption{$X_1$}
\label{produkt_a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.35\textwidth}
\centering
\resizebox{0.7\textwidth}{!}{%
\begin{tikzpicture}
\node (1) at (0,0) {a};
\node (2) at (-1.5,1.5) {b};
\node (3) at (0,1.5) {c};
\node (4) at (1.5,1.5) {d};
\node (5) at (0,3) {e};
\draw[green] (1)--(2) --(5) --cycle;
\draw[green] (1)--(3) --(5) --cycle;
\draw[green] (1)--(4) --(5) --cycle;
\end{tikzpicture}}
\caption{$X_2$}
\label{produkt_b}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.3\textwidth}
\centering
\resizebox{1\textwidth}{!}{%
\begin{tikzpicture}
\node (A1) at ( -2, 0) {$(1,a)$};
\node (B3) at (1, 3) {$(2,a)$};
\node (B4) at (-1, 3) {$(1,d)$};
\node (B5) at ( -3, 3) {$(1,c)$};
\node (B6) at ( -5, 3) {$(1,b)$};
\node (C1) at ( -3, 6) {$(2,b)$};
\node (D2) at (1,6) {$(2,d)$};
\node (D3) at ( -1,6) {$(2,c)$};
\node (D4) at ( -5,6) {$(1,e)$};
\node (E1) at ( -2,9) {$(2,e)$};
\path[thick, green] (A1) edge (B6);
\path[thick, green] (A1) edge (B5);
\path[thick, green] (A1) edge (B4);
\path[thick, green] (B6) edge (D4);
\path[thick, green] (B5) edge (D4);
\path[thick, green] (B4) edge (D4);
\path[thick, green] (C1) edge (B3);
\path[thick, green] (B3) edge (D2);
\path[thick, red] (B3) edge (D3);
\path[thick, green] (C1) edge (E1);
\path[thick, green] (D2) edge (E1);
\path[thick, green] (D3) edge (E1);
\path[thick, red] (D4) edge (E1);
\path[thick, red] (A1) edge (B3);
\path[thick, red] (B6) edge (D3);
\path[thick, red] (B4) edge (C1);
\path[thick, red] (B5) edge (D2);
\end{tikzpicture}}
\caption{$X_1\times X_2$}
\label{produkt_c}
\end{subfigure}
\end{figure}
\end{document}
答案1
\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}{0.1\textwidth}
\centering
\begin{tikzpicture}[scale=0.5]
\node (1) at (0,0) {$1$};
\node (2) at (0,9) {$2$};
\draw[red] (1)--(2);
\end{tikzpicture}
\caption{$X_1$}
\label{produkt_a}
\end{subfigure}
\hfill \raisebox{7.5pt}{$\times$} \hfill
\begin{subfigure}{0.425\textwidth}
\centering
\begin{tikzpicture}[scale=0.5]
\node (1) at (0,0) {a};
\node (2) at (-4.5,4.5) {b};
\node (3) at (0,4.5) {c};
\node (4) at (4.5,4.5) {d};
\node (5) at (0,9) {e};
\draw[green] (1)--(2) --(5) --cycle;
\draw[green] (1)--(3) --(5) --cycle;
\draw[green] (1)--(4) --(5) --cycle;
\end{tikzpicture}
\caption{$X_2$}
\label{produkt_b}
\end{subfigure}
\hfill \raisebox{7.5pt}{$=$} \hfill
\begin{subfigure}{0.35\textwidth}
\centering
\begin{tikzpicture}[scale=0.5]
\node (A1) at ( -2, 0) {$(1,a)$};
\node (B3) at (1, 3) {$(2,a)$};
\node (B4) at (-1, 3) {$(1,d)$};
\node (B5) at ( -3, 3) {$(1,c)$};
\node (B6) at ( -5, 3) {$(1,b)$};
\node (C1) at ( -3, 6) {$(2,b)$};
\node (D2) at (1,6) {$(2,d)$};
\node (D3) at ( -1,6) {$(2,c)$};
\node (D4) at ( -5,6) {$(1,e)$};
\node (E1) at ( -2,9) {$(2,e)$};
\path[thick, green] (A1) edge (B6);
\path[thick, green] (A1) edge (B5);
\path[thick, green] (A1) edge (B4);
\path[thick, green] (B6) edge (D4);
\path[thick, green] (B5) edge (D4);
\path[thick, green] (B4) edge (D4);
\path[thick, green] (C1) edge (B3);
\path[thick, green] (B3) edge (D2);
\path[thick, red] (B3) edge (D3);
\path[thick, green] (C1) edge (E1);
\path[thick, green] (D2) edge (E1);
\path[thick, green] (D3) edge (E1);
\path[thick, red] (D4) edge (E1);
\path[thick, red] (A1) edge (B3);
\path[thick, red] (B6) edge (D3);
\path[thick, red] (B4) edge (C1);
\path[thick, red] (B5) edge (D2);
\end{tikzpicture}
\caption{$X_1\times X_2$}
\label{produkt_c}
\end{subfigure}
\end{figure}
\end{document}
答案2
编辑: 呃,我没有上传最新版本的图片和代码。现在更正一下:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[export]{adjustbox}
\usepackage[active,floats, tightpage]{preview}
\setlength\PreviewBorder{1em}
\begin{document}
\begin{figure}
\centering
\tikzset{every node/.append style = {text height=2.2ex, text depth=0.5ex}}
\begin{subfigure}{0.08\textwidth}
\centering
\begin{tikzpicture}[
node distance = 60mm and 0mm, on grid
]
\node (1) {$1$};
\node (2) [above=of 1] {$2$};
\draw[red] (1) -- (2);
\end{tikzpicture}
\caption{$X_1$}
\label{produkt_a}
\end{subfigure}
\raisebox{1.7ex}{$\times$}
\begin{subfigure}{0.3\textwidth}
\centering
\begin{tikzpicture}[
node distance = 30mm and 15mm, on grid
]
\node (1) {a};
\node (2) [above left=of 1] {b};
\node (3) [above=of 1] {c};
\node (4) [above right=of 1] {d};
\node (5) [above=of 3] {e};
%
\draw[green] (1) -- (3) --(5)
(1) -- (2) --(5) -- (4) -- (1);
\end{tikzpicture}
\caption{$X_2$}
\label{produkt_b}
\end{subfigure}
\raisebox{1.8ex}{$=$}
\begin{subfigure}{0.5\textwidth}
\centering
\begin{tikzpicture}[
node distance = 20mm and 15mm, on grid
]
\node (A1) {$(1,a)$};
%
\node (B2) [above=of A1,xshift=-7.5mm] {$(1,c)$};
\node (B3) [above=of A1,xshift=+7.5mm] {$(1,d)$};
\node (B1) [left =of B2] {$(1,b)$};
\node (B4) [right=of B3] {$(2,a)$};
%
\node (C1) [above=of B1] {$(1,e)$};
\node (C2) [above=of B2] {$(2,b)$};
\node (C3) [above=of B3] {$(2,c)$};
\node (C4) [above=of B4] {$(2,d)$};
%
\node (D1) [above=of C2.south -| A1] {$(2,e)$};
%
\draw[thick, green]
(A1) -- (B1) -- (C1)
(A1) -- (B2) -- (C1)
(A1) -- (B3) -- (C1)
%
(B4) -- (C2) -- (D1)
(B4) -- (C3) -- (D1)
(B4) -- (C4) -- (D1);
%
\draw[thick, red]
(A1) -- (B4)
(B1) -- (C3)
(B2) -- (C4)
(B3) -- (C2)
%
(C1) -- (D1);
\end{tikzpicture}
\caption{$X_1\times X_2$}
\label{produkt_c}
\end{subfigure}
\end{figure}
\end{document}
我从您的 MWE 中删除了\resizebox
。节点通过使用相对坐标相对于彼此定位。之间的距离通过使用 来确定\node distance
,这在每个子图中都有相应的定义。图像之间的数学符号位于\risebox
es 中,这可以微调它们的垂直定位。