我用以下代码生成了此图。它溢出了。如何使其适合页面宽度?
\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}
我包含了 textwidth 变量但它不起作用。
\begin{figure}[width=\textwidth]
...
...
...
\end{figure}
答案1
除非有更多的事情发生,我认为一个简单的表格就足以解决你的问题
\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{graphicx}
\begin{document}
\begin{figure}[tbh]
\setlength{\tabcolsep}{2pt}
\centering
\begin{tabularx}{\textwidth}{@{}*6{X}@{}}
\multicolumn{3}{c}{Reconstruct} & \multicolumn{3}{c}{Forecast} \\
\midrule
\includegraphics[width=\linewidth]{example-image-a}
& \includegraphics[width=\linewidth]{example-image-a}
& \includegraphics[width=\linewidth]{example-image-a}
& \includegraphics[width=\linewidth]{example-image-a}
& \includegraphics[width=\linewidth]{example-image-a}
& \includegraphics[width=\linewidth]{example-image-a}
\end{tabularx}
\caption{Given the historical human and object motion}\label{fig:intro}
\end{figure}
\end{document}