텍스트 너비를 기준으로 세 개의 그림을 나란히 정렬

텍스트 너비를 기준으로 세 개의 그림을 나란히 정렬

문제:

세 개의 그림을 나란히 정렬하고 각 그림의 중앙에 텍스트를 정렬하려고 합니다. 세 번째 상자의 상자가 텍스트 너비 이후에 조정되지 않을 때까지는 잘 진행됩니다.

최소 작업 예(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}

출력:

여기에 이미지 설명을 입력하세요 요망되는 결과:

"임시 정보"를 두 줄이 아닌 한 줄로 작성할 수 있도록 텍스트 뒤의 너비를 조정합니다.

답변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}

여기에 이미지 설명을 입력하세요

관련 정보