如何在 Latex 中将下图并排放置

如何在 Latex 中将下图并排放置
\documentclass[12pt,a4paper]{article}
\usepackage{tikz}


\begin{document}

\begin{center}

%\textit{$U$}
 \begin{tikzpicture}[scale=0.80,
       thick,
       acteur/.style={
         circle,
         fill=purple,
         thick,
         inner sep=1pt,
         minimum size=0.2cm
       }
     ] 


           \node (a1) at (0,0) [acteur,label=below:1]{};
           \node (a2) at (0,2)[acteur,label=above:2]{}; 
           \node (a3) at (1.4,1) [acteur,label=below :3]{}; 
           \node (a4) at (3.4,1) [acteur,label=below:4]{}; 
           \node (a5) at (4.8,0) [acteur,label=below:5]{}; 
           \node (a6) at (4.8,2) [acteur,label=above:6]{};


           \draw  (a1) -- (a2); 
           \draw [dashed] (a2) -- (a3); 
           \draw(a3) -- (a4);
           \draw [dashed] (a1) -- (a3);
           \draw [dashed] (a4) -- (a6);
           \draw [dashed] (a4) -- (a5);
           \draw (a5) -- (a6);
          %\draw (-2.4, 3) node {$G$};


         \end{tikzpicture} 
%\hspace{2mm}
%\textit{$U^{+}$}
  \begin{tikzpicture}[scale=0.80,
       thick,
       acteur/.style={
         circle,
         fill=blue,
         thick,
         inner sep=1pt,
         minimum size=0.2cm
       }
     ] 


           \node (a1) at (0,0) [acteur,label=below:1]{};
           \node (a2) at (0,2)[acteur,label=above:2]{}; 
           \node (a3) at (1.4,1) [acteur,label=below :3]{}; 
           \node (a4) at (2.9,1) [acteur,label=below:4]{}; 
           \node (a5) at (2.9,2.2) [acteur,label=above:5]{};
           \node (a6) at (4.2,2.2) [acteur,label=above:6]{};
           \node (a7) at (4.2,1) [acteur,label=below:7]{}; 
           \node (a8) at (5.6,1) [acteur,label=below :8]{}; 



           \draw  (a1) -- (a2); 
           \draw [dashed] (a2) -- (a3); 
           \draw(a3) -- (a4);
           \draw [dashed] (a1) -- (a3);
           \draw [dashed] (a4) -- (a5);
           \draw (a5) -- (a6);
           \draw [dashed] (a6) -- (a7);
           \draw [dashed] (a4) -- (a7);
           \draw  (a7) -- (a8);
           % \draw (-2.4, 3) node {$H$};


         \end{tikzpicture} 
         %\hspace{2mm}

\begin{tikzpicture}[scale=0.10,
       thick,
       acteur/.style={
         circle,
         fill=violet,
         thick,
         inner sep=1pt,
         minimum size=0.2cm
       }
     ] 


           \node (a1) at (0,0) [acteur,label=below:1]{};
           \node (a2) at (1.4,0)[acteur,label=below:2]{}; 
           \node (a5) at (2.8,0) [acteur,label=below :5]{}; 
           \node (a6) at (4.2,0) [acteur,label=below:6]{}; 
           \node (a9) at (5.6,0) [acteur,label=below:9]{};
           \node (a10) at (7,0) [acteur,label=below:10]{};
           \node (a7) at (4.2,1) [acteur,label=left:7]{}; 
           \node (a8) at (5.6,1) [acteur,label=right :8]{};
           \node (a4) at (2.1,1) [acteur,label=left :4]{};
           \node (a3) at (2.1,2) [acteur,label=left:3]{};



           \draw  (a1) -- (a2); 
           \draw [dashed] (a2) -- (a5); 
           \draw (a5) -- (a6);
           \draw [dashed] (a6) -- (a9);
           \draw (a9) -- (a10);
           \draw [dashed](a8) -- (a9);
           \draw [dashed] (a6) -- (a7);
           \draw [dashed] (a4) -- (a2);
           \draw [dashed] (a4) -- (a5);
           \draw (a4) -- (a3);
           \draw (a7) -- (a8);
         %  \draw (-1.4, 2) node {$K$};


         \end{tikzpicture} 


\end{center}
\end{document}

我想将三个图形并排放置在同一水平位置。该怎么做?

答案1

  1. scope为了对齐用 TikZ 构建的图形,只需在环境中构建每个图形并将其构建到shift后者即可。

  2. 我用 对每个图形的选项进行分解\tikzset,从而简化了代码:

    \tikzset{every path/.style=thick,
           acteur/.style={
             circle,
             fill=blue,
             thick,
             inner sep=1pt,
             minimum size=0.2cm
           }}

  3. 要在三个图形的中间和下方写一段文字,只需将它们包含在另一个scope环境中即可。此环境本身定义了一个名为的边界框current bounding box。只需将此文本放置在south此框的 上,并将anchor其放置在 上,north这样文本就不会与 3 个图形重叠。

    \node[anchor=north] at (current bounding box.south){The solid edges are the matching edges};

截屏

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

\tikzset{every path/.style=thick,
       acteur/.style={
         circle,
         fill=blue,
         thick,
         inner sep=1pt,
         minimum size=0.2cm
       }}

\begin{document}

\begin{center}

\begin{tikzpicture}[scale=.7]
\begin{scope}
\begin{scope}
           \node (a1) at (0,0) [acteur,label=below:1]{};
           \node (a2) at (0,2)[acteur,label=above:2]{}; 
           \node (a3) at (1.4,1) [acteur,label=below :3]{}; 
           \node (a4) at (3.4,1) [acteur,label=below:4]{}; 
           \node (a5) at (4.8,0) [acteur,label=below:5]{}; 
           \node (a6) at (4.8,2) [acteur,label=above:6]{};

           \draw  (a1) -- (a2); 
           \draw [dashed] (a2) -- (a3); 
           \draw(a3) -- (a4);
           \draw [dashed] (a1) -- (a3);
           \draw [dashed] (a4) -- (a6);
           \draw [dashed] (a4) -- (a5);
           \draw (a5) -- (a6);
          %\draw (-2.4, 3) node {$G$};
\end{scope}

\begin{scope}[xshift=6cm]
           \node (a1) at (0,0) [acteur,label=below:1]{};
           \node (a2) at (0,2)[acteur,label=above:2]{}; 
           \node (a3) at (1.4,1) [acteur,label=below :3]{}; 
           \node (a4) at (2.9,1) [acteur,label=below:4]{}; 
           \node (a5) at (2.9,2.2) [acteur,label=above:5]{};
           \node (a6) at (4.2,2.2) [acteur,label=above:6]{};
           \node (a7) at (4.2,1) [acteur,label=below:7]{}; 
           \node (a8) at (5.6,1) [acteur,label=below :8]{}; 



           \draw  (a1) -- (a2); 
           \draw [dashed] (a2) -- (a3); 
           \draw(a3) -- (a4);
           \draw [dashed] (a1) -- (a3);
           \draw [dashed] (a4) -- (a5);
           \draw (a5) -- (a6);
           \draw [dashed] (a6) -- (a7);
           \draw [dashed] (a4) -- (a7);
           \draw  (a7) -- (a8);
           % \draw (-2.4, 3) node {$H$};
\end{scope} 

\begin{scope}[shift={(13,1)}] 
           \node (a1) at (0,0) [acteur,label=below:1]{};
           \node (a2) at (1.4,0)[acteur,label=below:2]{}; 
           \node (a5) at (2.8,0) [acteur,label=below :5]{}; 
           \node (a6) at (4.2,0) [acteur,label=below:6]{}; 
           \node (a9) at (5.6,0) [acteur,label=below:9]{};
           \node (a10) at (7,0) [acteur,label=below:10]{};
           \node (a7) at (4.2,1) [acteur,label=left:7]{}; 
           \node (a8) at (5.6,1) [acteur,label=right :8]{};
           \node (a4) at (2.1,1) [acteur,label=left :4]{};
           \node (a3) at (2.1,2) [acteur,label=left:3]{};

           \draw  (a1) -- (a2); 
           \draw [dashed] (a2) -- (a5); 
           \draw (a5) -- (a6);
           \draw [dashed] (a6) -- (a9);
           \draw (a9) -- (a10);
           \draw [dashed](a8) -- (a9);
           \draw [dashed] (a6) -- (a7);
           \draw [dashed] (a4) -- (a2);
           \draw [dashed] (a4) -- (a5);
           \draw (a4) -- (a3);
           \draw (a7) -- (a8);
         %  \draw (-1.4, 2) node {$K$};
\end{scope}
\end{scope}
\node[anchor=north] at (current bounding box.south){The solid edges are the matching edges};
         \end{tikzpicture} 

\end{center}
\end{document}

相关内容