# Centering 2 tikz pictures

\begin{tikzpicture}[declare function={f(\x,\y)=3-2*\y;}]
\def\xmax{3} \def\xmin{-3}
\def\ymax{3} \def\ymin{-3}
\def\nx{15}
\def\ny{15}

\pgfmathsetmacro{\hx}{(\xmax-\xmin)/\nx}
\pgfmathsetmacro{\hy}{(\ymax-\ymin)/\ny}
\foreach \i in {0,...,\nx}
\foreach \j in {0,...,\ny}{
\pgfmathsetmacro{\yprime}{f({\xmin+\i*\hx},{\ymin+\j*\hy})}
\draw[blue,shift={({\xmin+\i*\hx},{\ymin+\j*\hy})}]
(0,0)--($(0,0)!2mm!(.1,.1*\yprime)$);
}

\def\yo{1}
\draw[magenta] plot[domain=\xmin:.9] (\x,{3/2});

\draw[->] (\xmin-.5,0)--(\xmax+.5,0) node[below right] {$x$};
\draw[->] (0,\ymin-.5)--(0,\ymax+.5) node[above left] {$y$};
\draw (current bounding box.north) node[above]
{Slope field of \quad $y'=3-2$.};
\end{tikzpicture}
\begin{tikzpicture}[declare function={f(\x,\y)=3-2*\y;}]
\def\xmax{3} \def\xmin{-3}
\def\ymax{3} \def\ymin{-3}
\def\nx{15}
\def\ny{15}

\pgfmathsetmacro{\hx}{(\xmax-\xmin)/\nx}
\pgfmathsetmacro{\hy}{(\ymax-\ymin)/\ny}
\foreach \i in {0,...,\nx}
\foreach \j in {0,...,\ny}{
\pgfmathsetmacro{\yprime}{f({\xmin+\i*\hx},{\ymin+\j*\hy})}
\draw[blue,shift={({\xmin+\i*\hx},{\ymin+\j*\hy})}]
(0,0)--($(0,0)!2mm!(.1,.1*\yprime)$);
}

\def\yo{1}
\draw[magenta] plot[domain=\xmin:.9] (\x,{3/2});

\draw[->] (\xmin-.5,0)--(\xmax+.5,0) node[below right] {$x$};
\draw[->] (0,\ymin-.5)--(0,\ymax+.5) node[above left] {$y$};
\draw (current bounding box.north) node[above]
{Slope field of \quad $y'=3-2$.};
\end{tikzpicture}


How can I align these 2 figures next to each other properly centered to the page.

They look like this when I compile it.

• for example: \begin{center} <images˙code> \end{center} or \begin{figure}[ht]\centering <images code> \end{figure}. Fo further help, please extend your code snippet to complete small document beginning with \documentclass ... and end with \end{document}. Nov 4, 2022 at 23:25
• But these are not images how can I use <images˙code> and I will have in total 6 of these graphs, I want to align them as 2 each row Nov 4, 2022 at 23:39
• Of course they are/is image(s) drawn by tikz. Insert your tikzpicture in center or figure environment as I already suggest you. For more help, please again, extend your code fragment to complete small document. Nov 4, 2022 at 23:53
• If your pictures are too wide, they will extend into the right margin and give an overfull \hbox warning. You can extend into the left and right margins equally using \makebox[\textwidth]{...} Nov 5, 2022 at 1:51