
Problem:
Ich versuche, drei Abbildungen nebeneinander auszurichten, wobei der Text auf jede Abbildung zentriert ist. Das funktioniert gut, bis sich das Feld für das dritte Feld nicht mehr an die Textbreite anpasst.
Minimales Arbeitsbeispiel (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}
Ausgaben:
Damit lässt sich die Breite nach dem Text anpassen, so dass „Temporäre Informationen“ in einer Zeile statt in zwei Zeilen geschrieben werden kann.
Antwort1
Hier ist eine Lösung
\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}