将许多 TikZ 绘图放在一页中

将许多 TikZ 绘图放在一页中

我在对齐使用 TikZ 制作的许多绘图时遇到了一些问题:我希望下面显示的这些 TikZ 图像能够像示例中那样显示:

在此处输入图片描述

但最后我的图片排列成了空白:

在此处输入图片描述

我该如何解决这个问题。

\documentclass[12pt]{article}
\usepackage[russian]{babel}

\usepackage{siunitx}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{arrows}
\usepackage[europeanresistors]{circuitikz}
\usetikzlibrary{positioning}
\usepackage{geometry}
\usepackage{adjustbox}
\usepackage{caption}

 \usepackage{amsmath}
 \usetikzlibrary{arrows.meta}
 \usetikzlibrary{patterns}
  \usepackage{mathrsfs}
 \newcommand{\EDS}{\ensuremath{\mathscr{E}}}
 \usepackage{enumitem}
 
\usetikzlibrary{datavisualization}

%Image-related packages
\usepackage{graphicx}
\usepackage{subcaption}
\usetikzlibrary{arrows}




\begin{document}



\begin{figure}[h]
    \halign{\hfil#\hfil&\hfil#\hfil&\hfil#\hfil\cr
    \parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]

    \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);


\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
&\parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]
    
    \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);


      
    

\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
 &\parbox[b]{0.33\textwidth}{\centerline{ 
 
 \begin{circuitikz}[european]
 \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);
    
   
    
\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}\cr}
\end{figure}


\begin{figure}[h]
    \halign{\hfil#\hfil&\hfil#\hfil&\hfil#\hfil\cr
    \parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]

     \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);


\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
&\parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]
    
      \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);

      
    

\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
 &\parbox[b]{0.33\textwidth}{\centerline{ 
 
 \begin{circuitikz}[european]
 
         \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);
    
   
    
\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}\cr}
\end{figure}


\begin{figure}[h]
    \halign{\hfil#\hfil&\hfil#\hfil&\hfil#\hfil\cr
    \parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]

    \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);


\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
&\parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]
    
        \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);


      
    

\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
 &\parbox[b]{0.33\textwidth}{\centerline{ 
 
 \begin{circuitikz}[european]
 
        \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);
    
   
    
\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}\cr}
\end{figure}


\begin{figure}[h]
    \halign{\hfil#\hfil&\hfil#\hfil&\hfil#\hfil\cr
    \parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]

        \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);



\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
&\parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]
    
        \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);

      
    



  \end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
     &\parbox[b]{0.33\textwidth}{\centerline{ 
 
 \begin{circuitikz}[european]
 
         \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);
    
   
    
\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}\cr}
\end{figure}

\begin{figure}[h]
    \halign{\hfil#\hfil&\hfil#\hfil&\hfil#\hfil\cr
    \parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]

        \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);




  \end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
    &\parbox[b]{0.33\textwidth}{\centerline{ 


\begin{circuitikz}[european]
    
      \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);



 \end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}
     &\parbox[b]{0.33\textwidth}{\centerline{ 
 
 \begin{circuitikz}[european]
 
         \newcommand{\potol}[3]{\pgfmathsetmacro{\x}{#1}\pgfmathsetmacro{\y}{#2}
\pgfmathsetmacro{\L}{#3}
    \draw[thick] (\x,\y) -- ++(\L,0); \draw (\x,\y+0.1) -- ++(0.1,0.1);
    \foreach \p in {0.2,0.3,...,\L} \draw ({\x+\p-0.2},\y) -- ++(0.2,0.2); \draw ({\x+\L-0.2},\y) -- ++(0.2,0.2);
    \draw ({\x+\L-0.1},\y) -- ++(0.1,0.1);}
      \potol{-0.5}{2.5}{1};
      \draw (0,2.5) -- (0,0);
      \filldraw[draw=black,fill=lightgray] (0,0) circle (.4);
    
   
    
\end{circuitikz}}\vspace{-0.2cm}\caption{}\label{}}\cr}
\end{figure}

\end{document}

答案1

如果您不需要浮动,请不要使用figure:只需将图片放在您需要的位置。Atikzpicture只是 LaTeX 的一个框,与字母完全相同。

您的 MWE 一点也不简单,所以我又做了一个。我为两张图片定义了两个命令,仅作为示例,并定义了它们的“基线”在哪里 --- 它们将在该级别对齐。然后我使用将use as a bounding box图片设置为固定大小,以便它们可以很好地垂直堆叠。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\newcommand{\drawingA}{%
    \begin{tikzpicture}[baseline=(A.base)]
        % set a fixed size for the picture
        \path[use as bounding box] (-2,-2) rectangle (2,2);
        \draw[thick] node[draw, circle, fill=yellow](A) {A} (A.south) -- ++(0,-1);
    \end{tikzpicture}%
}
\newcommand{\drawingB}{%
    \begin{tikzpicture}[baseline=(A.base)]
        % set a fixed size for the picture
        \path[use as bounding box] (-2,-2) rectangle (2,2);
        \draw[thick] (0,0) node[draw, rectangle, fill=cyan](B) {B}
            (B.south) ++(-1,0) -- ++(2,0);
    \end{tikzpicture}%
}
\parindent=0pt
\begin{document}
    \drawingA \drawingA \drawingB \par
    \drawingB \drawingA \drawingB \par
\end{document}

在此处输入图片描述

相关内容