
問題:
3 つの図を並べて、各図の中央にテキストを配置しようとしています。3 番目のボックスのボックスがテキスト幅に合わせて調整されなくなるまでは、うまくいっています。
最小限の動作例 (MWE):
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\begin{figure}[!tbp]
\centering
\begin{minipage}[b]{0.2\textwidth}
\includegraphics[width=\textwidth]{icon-password.eps}
\caption*{Login system}
\end{minipage}
\hfill
\begin{minipage}[b]{0.2\textwidth}
\includegraphics[width=\textwidth]{icon-shopping.eps}
\caption*{Shopping cart}
\end{minipage}
\hfill
\begin{minipage}[b]{0.2\textwidth}
\includegraphics[width=\textwidth]{icon-clock.eps}
\caption*{Temporary information}
\end{minipage}
\end{figure}
\end{document}
出力:
「臨時情報」を 2 行ではなく 1 行で書き出せるように、テキストの後の横幅を調整します。
答え1
解決策はここにあります
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\newlength{\mtfiglength}
\newcommand{\mtfigure}[3][\textwidth]{% #1 optional with of figure #2 caption #3 image filename
\settowidth{\mtfiglength}{#2}%
\begin{minipage}[b]{\mtfiglength}
\centering
\includegraphics[width=#1]{#3}
\caption*{#2}
\end{minipage}}
\begin{document}
\begin{figure}[!tbp]
\centering
\mtfigure{Login system}{example-image-a}\hfill
\mtfigure{Shopping cart}{example-image-b}\hfill
\mtfigure{Temporary information}{example-image}
\end{figure}
\begin{figure}[!tbp]
\centering
\mtfigure{Login system}{example-image-a}\hfill
\mtfigure{Shopping cart}{example-image-b}\hfill
\mtfigure[3cm]{Temporary information}{example-image}
\end{figure}
\end{document}