I have this figure generated by the following code. It is overflowing. How do I make it fit the page width?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{tabularray} % https://www.latex-tables.com/#
\usepackage{amsmath}
\usepackage{float}
\usepackage{subfig}
\usepackage{graphicx}
\usepackage{tikz}% loads graphicx
\usetikzlibrary{calc}
\usetikzlibrary{chains}
\begin{document}
\begin{figure}
\begin{tikzpicture}[start chain=g going right,node distance=1mm,
nodes={inner sep=0,on chain}]
\node[anchor=south west] (image) at (0,0) {\includegraphics[width=0.2\textwidth,trim={0 50 0 0},clip]{example-image-a}};
\node {\includegraphics[width=0.2\textwidth]{example-image-a}};
\node {\includegraphics[width=0.2\textwidth]{example-image-a}};
\node {\includegraphics[width=0.2\textwidth]{example-image-a}};
\node {\includegraphics[width=0.2\textwidth]{example-image-a}};
\node {\includegraphics[width=0.2\textwidth]{example-image-a}};
\draw (g-begin.north west|-g-end.north)+(0,1mm) -- ([xshift=-5cm,yshift=1mm]g-end.north east);
\draw (g-begin.north west|-g-end.north)+(8cm,0mm) -- ([xshift=0,yshift=0mm]g-end.north east);
\node[] at (3cm,2cm) {Reconstruct};
\node[] at (8cm,2cm) {Forecast};
\end{tikzpicture}
\caption{Given the historical human and object motion}
\label{fig:intro}
\end{figure}
\end{document}
I included the textwidth variable but it does not work.
\begin{figure}[width=\textwidth]
...
...
...
\end{figure}

