TeX - LaTeX Asked by Ildar on July 28, 2021
I’ve some problems with aligning many drawings I made with TikZ: I want these TikZ pictured below to be displayed like in example:
But finally my pictures aranged with blank space:
How can I fix this issue.
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#hfilcr
parbox[b]{0.33textwidth}{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.33textwidth}{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.33textwidth}{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#hfilcr
parbox[b]{0.33textwidth}{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.33textwidth}{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.33textwidth}{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#hfilcr
parbox[b]{0.33textwidth}{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.33textwidth}{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.33textwidth}{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#hfilcr
parbox[b]{0.33textwidth}{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.33textwidth}{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.33textwidth}{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#hfilcr
parbox[b]{0.33textwidth}{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.33textwidth}{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.33textwidth}{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}
If you do not need to float things, do not use figure
: simply put the picture where you need them. A tikzpicture
is just a box for LaTeX, exactly the same as a letter.
Your MWE is not Minimal at all, so I made another one. I define two commands for two pictures, just as example, and define where they "baselines" are --- they will be aligned at that level. Then I use the use as a bounding box
to make the picture a fixed size so that they will stack nicely vertically.
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}
Answered by Rmano on July 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP