1

I'm new to Latex and I have problems with how to align captions and figures. I need all figures to be in line and all captions to be aligned left and right. Ive tried many things, read many things. But like I said Im new to Latex and I have problems. I would be very thankful if anyone can help me.

What I have: enter image description here

What I want: enter image description here

 \begin{figure}[!ht]
\centering
% ~~~~~~~~~~~
 \begin{subfigure}{0.32\linewidth}
 \includegraphics[width=0.82\linewidth]{Figures/ConfigManagerRename2}
 \caption{Choose configuration to rename.}
  \label{f:configmanagerlist}
 \end{subfigure}
% ~~~~~~~~~~~
 \begin{subfigure}{0.32\linewidth}
 \includegraphics[width=0.82\linewidth]{Figures/ConfigManagerRename1}
 \caption{Select rename.}
 \label{f:savedconfopt}
 \end{subfigure}
% ~~~~~~~~~~~
 \begin{subfigure}{0.32\linewidth}
 \includegraphics[width=0.82\linewidth]{Figures/ConfigManagerRename}
 \caption{Choose new configuration name.}
  \label{f:renamesavedconf}
 \end{subfigure}
% ~~~~~~~~~~~
\caption{Config Manager - renaming selected configuration.}
\end{figure}

1 Answer 1

1

Use the optional parameter [c] (upper figure) or [t] (lower figure) to align the subfigures vertically.

c

\documentclass[12pt,a4paper]{article}

\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
    
     \begin{figure}[!ht]
        \centering
        % ~~~~~~~~~~~
        \begin{subfigure}[c]{0.32\linewidth}
            \includegraphics[width=0.82\linewidth,height=30pt]{example-image-a}
            \caption{Choose configuration to rename.}
            \label{f:configmanagerlist}
        \end{subfigure}
        % ~~~~~~~~~~~
        \begin{subfigure}[c]{0.32\linewidth}
            \includegraphics[width=0.82\linewidth,height=70pt]{example-image-b}
            \caption{Select rename.}
            \label{f:savedconfopt}
        \end{subfigure}
        % ~~~~~~~~~~~
        \begin{subfigure}[c]{0.32\linewidth}
            \includegraphics[width=0.82\linewidth,height=100pt]{example-image-c}
            \caption{Choose new configuration name.}
            \label{f:renamesavedconf}
        \end{subfigure}
        % ~~~~~~~~~~~
        \caption{Config Manager - renaming selected configuration.}
    \end{figure}

 \begin{figure}[!ht]
    \centering
    % ~~~~~~~~~~~
    \begin{subfigure}[t]{0.32\linewidth}
        \includegraphics[width=0.82\linewidth,height=30pt]{example-image-a}
        \caption{Choose configuration to rename.}
        \label{f:configmanagerlist}
    \end{subfigure}
    % ~~~~~~~~~~~
    \begin{subfigure}[t]{0.32\linewidth}
        \includegraphics[width=0.82\linewidth,height=70pt]{example-image-b}
        \caption{Select rename.}
        \label{f:savedconfopt}
    \end{subfigure}
    % ~~~~~~~~~~~
    \begin{subfigure}[t]{0.32\linewidth}
        \includegraphics[width=0.82\linewidth,height=100pt]{example-image-c}
        \caption{Choose new configuration name.}
        \label{f:renamesavedconf}
    \end{subfigure}
    % ~~~~~~~~~~~
    \caption{Config Manager - renaming selected configuration.}
    \end{figure}


\end{document}

Use the command \subcaptionbox to align the subfigures and its captions. Take a look at subcaption doc , section 2.

d

\documentclass[12pt,a4paper]{article}

\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}

\begin{figure}
    \centering
    \subcaptionbox{Choose configuration to rename.\label{f:one}}
    {\includegraphics[height=30pt,width=0.3\linewidth]{example-image-a}}\hfill
    \subcaptionbox{Select rename.\label{f:two}}
    {\includegraphics[height=50pt,width=0.3\linewidth]{example-image-b}}\hfill
    \subcaptionbox{Choose new configuration name.\label{f:three}}
    {\includegraphics[height=100pt,width=0.3\linewidth]{example-image-c}}
    \caption{Config Manager - renaming selected configuration.}
\end{figure}    

\end{document}
5
  • 1
    Thank you a lot, Mr. Simon. [t] (lower figure) works perfectly for figures. What about captions? Can they be aligned with figures on both ends?
    – Žan
    Jan 21, 2022 at 13:43
  • 1
    @Žan Please see the updated answer. Jan 21, 2022 at 14:20
  • 1
    You are the best. Thank you again.
    – Žan
    Jan 21, 2022 at 14:27
  • One more question Mr. Simon. Your solution works perfectly for me, thanks again. Is there a way to apply these settings for the whole document (macro) or do I need to change figures one by one?
    – Žan
    Jan 24, 2022 at 7:47
  • @Žan \subcaptionbox is a command that requires 2 parameters: the subfigure caption and the subfigure itself. Therefore, it must be called for each subfigure. Jan 24, 2022 at 13:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .