我怎样才能让两个图表并排显示,而不是一个图表叠在另一个图表之上?

我怎样才能让两个图表并排显示,而不是一个图表叠在另一个图表之上?

我怎样才能将这两个图表并排显示呢?

\begin{tikzpicture}  
  [->,scale=0.6,auto=center,every node/.style={circle,fill=blue!20}] 

  \node [label=left:t] (a1) at (1,7) {$\infty$};  
  \node [label=above:v] (a2) at (4,6.5)  {$\infty$}; 
  \node [label=right:u] (a3) at (7.5,7)  {$\infty$};  
  \node [label=left:w] (a4) at (1,4.6) {$\infty$};  
  \node [label=below right :x](a5) at (5,4.2)  {0};  
  \node [label=below:z] (a6) at (4.2,1.5)  {$\infty$};  
  \node [label=right:y] (a7) at (7.8,4.6)  {$\infty$};  

  \draw (a1) -- (a2)  ;
  \draw (a2) -- (a3);
\draw (a2) -- (a4);
\draw (a2) -- (a6);
\draw (a3) -- (a7);
\draw (a7) -- (a5);
\draw (a5) -- (a4);
\draw (a4) -- (a6);
\draw (a4) -- (a1);
\draw (a6) -- (a5);
\draw (a6) -- (a7);
\draw (a5) -- (a3);
\draw (a5) -- (a2);

\end{tikzpicture} 


\begin{tikzpicture}  
  [->,scale=0.6,auto=center,every node/.style={circle,fill=blue!20}] 

  \node (a1) at (1,7) {t};  
  \node (a2) at (4,6.5)  {v}; 
  \node (a3) at (7.5,7)  {u};  
  \node (a4) at (1,4.6) {w};  
  \node (a5) at (5,4.2)  {x};  
  \node (a6) at (4.2,1.5)  {z};  
  \node (a7) at (7.8,4.6)  {y};  

  \draw (a1) -- (a2);
  \draw (a2) -- (a3);
\draw (a2) -- (a4);
\draw (a2) -- (a6);
\draw (a3) -- (a7);
\draw (a7) -- (a5);
\draw (a5) -- (a4);
\draw (a4) -- (a6);
\draw (a4) -- (a1);
\draw (a6) -- (a5);
\draw (a6) -- (a7);
\draw (a5) -- (a3);
\draw (a5) -- (a2);

\end{tikzpicture}  

答案1

一种方法是使用 minipages:

\begin{minipage}[t]{0.5\textwidth}
    \begin{tikzpicture}
        % your stuff
    \end{tikzpicture}  
\end{minipage}%        <- This '%' is important
\begin{minipage}[t]{0.5\textwidth}
    \begin{tikzpicture}
        % your stuff
    \end{tikzpicture}
\end{minipage}

也可以使用 subcaption 包中的 subfigure :

\begin{figure}[hbt]
    \begin{subfigure}[b]{0.5\textwidth}
        % your stuff
        \caption{name of first subfigure}
    \end{subfigure}%    <- This '%' is important to prevent line break... I think you can also use ~
    \begin{subfigure}[b]{0.5\textwidth}
        % your stuff
        \caption{name of second subfigure}
    \end{subfigure}
\caption{name of figure}
\end{figure}

我希望这有帮助 ;-)

答案2

或者更简单,使用带有 xshift 的范围。 两张照片并排

\documentclass[12pt]{article}
\usepackage{tikz}

\begin{document}

    \begin{tikzpicture}  
      [->,scale=0.6,auto=center,every node/.style={circle,fill=blue!20}] 
    
      \node [label=left:t] (a1) at (1,7) {$\infty$};  
      \node [label=above:v] (a2) at (4,6.5)  {$\infty$}; 
      \node [label=right:u] (a3) at (7.5,7)  {$\infty$};  
      \node [label=left:w] (a4) at (1,4.6) {$\infty$};  
      \node [label=below right :x](a5) at (5,4.2)  {0};  
      \node [label=below:z] (a6) at (4.2,1.5)  {$\infty$};  
      \node [label=right:y] (a7) at (7.8,4.6)  {$\infty$};  
    
      \draw (a1) -- (a2)  ;
      \draw (a2) -- (a3);
    \draw (a2) -- (a4);
    \draw (a2) -- (a6);
    \draw (a3) -- (a7);
    \draw (a7) -- (a5);
    \draw (a5) -- (a4);
    \draw (a4) -- (a6);
    \draw (a4) -- (a1);
    \draw (a6) -- (a5);
    \draw (a6) -- (a7);
    \draw (a5) -- (a3);
    \draw (a5) -- (a2);

    \begin{scope}[xshift=10cm] 
    
      \node (a1) at (1,7) {t};  
      \node (a2) at (4,6.5)  {v}; 
      \node (a3) at (7.5,7)  {u};  
      \node (a4) at (1,4.6) {w};  
      \node (a5) at (5,4.2)  {x};  
      \node (a6) at (4.2,1.5)  {z};  
      \node (a7) at (7.8,4.6)  {y};  
    
      \draw (a1) -- (a2);
      \draw (a2) -- (a3);
    \draw (a2) -- (a4);
    \draw (a2) -- (a6);
    \draw (a3) -- (a7);
    \draw (a7) -- (a5);
    \draw (a5) -- (a4);
    \draw (a4) -- (a6);
    \draw (a4) -- (a1);
    \draw (a6) -- (a5);
    \draw (a6) -- (a7);
    \draw (a5) -- (a3);
    \draw (a5) -- (a2);
    \end{scope} 
    \end{tikzpicture}

\end{document}

答案3

tikzpicture由定位字母的相同代码来定位,因此您的问题与询问如何使两个 X 并排出现相同。

你有

X

X

所以它们一个接一个地出现。

你可以有

XX

并排放置,或

X
X

与单词 space 并排。

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}  
  [->,scale=0.6,auto=center,every node/.style={circle,fill=blue!20}] 

  \node [label=left:t] (a1) at (1,7) {$\infty$};  
  \node [label=above:v] (a2) at (4,6.5)  {$\infty$}; 
  \node [label=right:u] (a3) at (7.5,7)  {$\infty$};  
  \node [label=left:w] (a4) at (1,4.6) {$\infty$};  
  \node [label=below right :x](a5) at (5,4.2)  {0};  
  \node [label=below:z] (a6) at (4.2,1.5)  {$\infty$};  
  \node [label=right:y] (a7) at (7.8,4.6)  {$\infty$};  

  \draw (a1) -- (a2)  ;
  \draw (a2) -- (a3);
\draw (a2) -- (a4);
\draw (a2) -- (a6);
\draw (a3) -- (a7);
\draw (a7) -- (a5);
\draw (a5) -- (a4);
\draw (a4) -- (a6);
\draw (a4) -- (a1);
\draw (a6) -- (a5);
\draw (a6) -- (a7);
\draw (a5) -- (a3);
\draw (a5) -- (a2);

\end{tikzpicture} 
\begin{tikzpicture}  
  [->,scale=0.6,auto=center,every node/.style={circle,fill=blue!20}] 

  \node (a1) at (1,7) {t};  
  \node (a2) at (4,6.5)  {v}; 
  \node (a3) at (7.5,7)  {u};  
  \node (a4) at (1,4.6) {w};  
  \node (a5) at (5,4.2)  {x};  
  \node (a6) at (4.2,1.5)  {z};  
  \node (a7) at (7.8,4.6)  {y};  

  \draw (a1) -- (a2);
  \draw (a2) -- (a3);
\draw (a2) -- (a4);
\draw (a2) -- (a6);
\draw (a3) -- (a7);
\draw (a7) -- (a5);
\draw (a5) -- (a4);
\draw (a4) -- (a6);
\draw (a4) -- (a1);
\draw (a6) -- (a5);
\draw (a6) -- (a7);
\draw (a5) -- (a3);
\draw (a5) -- (a2);

\end{tikzpicture} 
\end{document}

在此处输入图片描述

相关内容