1

I would like to create a figure with a left-aligned subfloat caption as the following:

\documentclass{llncs}

\usepackage{todonotes}
\usepackage{floatflt}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}
\begin{figure}[t!]
    \centering
    \subfloat[Resource Owner Password \hspace{\textwidth}Credential Grant]{
        \missingfigure[figwidth=0.5\textwidth]{Testing a long text string}
        \label{fig:pwd_grant}
    }
    \subfloat[Client Credential Grant]{
        \missingfigure[figwidth=0.5\textwidth]{Testing a long text string}
        \label{fig:client_grant}
    }
    \caption{grants}
    \label{fig:auth_impl_grant}
\end{figure}
\end{document}

(if you compile now the example you will see the actual problem with the caption and why I would wish to have it left aligned)

using the subfig package with documenttype lncs currently the caption is in block mode - means tex spreads it over the complete available distance. This looks pretty crappy to me...

Thank you very much in advance.

@Peiffap Thanks to your suggestion I was able to create an example that worked for me with left aligned caption, but also in height aligned caption, it looks as follows:

\documentclass{llncs}
\usepackage{todonotes}
\usepackage{floatflt}
\usepackage{graphicx}
\usepackage{subcaption}
\captionsetup{compatibility=false}

\begin{document}
\begin{figure}[t!]
    \makebox[\linewidth][c]{
        \subcaptionbox{Resource Owner Password\\ Credential Grant}[.47\linewidth]{
            \missingfigure[figwidth=\textwidth]{Testing a text string}
            \label{fig:auth_grant}
        }
        \hspace*{2cm}
        \subcaptionbox{Client Credential Grant}[.47\linewidth]{
            \centering
            \missingfigure[figwidth=\textwidth]{Testing a text string}
            \label{fig:impl_grant}
        }
    }
    \caption{Caption}
    \label{fig:auth_impl_grant}
\end{figure}


\end{document}

for some odd reason, when I put this into overleaf with the missing figure placeholder it looks odd, still locally it works totally fine.

| improve this question | | | | |
  • I hope the code snippet is now completly functional – Silence and I Mar 18 '19 at 12:44
  • Why \hspace{\textwidth}? – user156344 Mar 18 '19 at 12:52
  • To create a linebreak in a caption, I would like to split the caption over two lines that it doesn't collide with the caption of figure (b) – Silence and I Mar 18 '19 at 12:53
  • That will definitely cause a warning. You have a much simpler command: \\ – user156344 Mar 18 '19 at 12:57
  • this doesn't compile on my machine, I mean of course I know \\ but I already googled this workaround to be able to produce a linebreak in a caption – Silence and I Mar 18 '19 at 13:03
1

Using the subcaption package, I could make the following.

This is the code I used to generate that (admittedly, I didn't have the llncs package installed, so I changed that out for article).

\documentclass{article}
\usepackage{todonotes}
\usepackage{floatflt}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure}[t!]
    \centering
    \begin{subfigure}[t]{0.47\textwidth}
        \centering
        \missingfigure[figwidth=\textwidth]{Testing a long text string}
        \caption{Resource Owner Password \\ Credential Grant}
        \label{fig:pwd_grant}
    \end{subfigure}\hfill
    \begin{subfigure}[t]{0.47\textwidth}
        \centering
        \missingfigure[figwidth=\textwidth]{Testing a long text string}
        \caption{Client Credential Grant}
        \label{fig:client_grant}
    \end{subfigure}
    \caption{grants}
    \label{fig:auth_impl_grant}
\end{figure}

\end{document}

Do note however that subcaption and subfig are not compatible! For what it's worth though, subfig was getting pretty obsolete last time I checked, while subcaption fixes some of its flaws (compatibility with hyperref being a big one).

Edit

After some more work, OP went with the following code.

\documentclass{llncs}
\usepackage{todonotes}
\usepackage{floatflt}
\usepackage{graphicx}
\usepackage{subcaption}
\captionsetup{compatibility=false}

\begin{document}
\begin{figure}[t!]
    \makebox[\linewidth][c]{
        \subcaptionbox{Resource Owner Password\\ Credential Grant}[.47\linewidth]{
            \missingfigure[figwidth=\textwidth]{Testing a text string}
            \label{fig:auth_grant}
        }
        \hspace*{2cm}
        \subcaptionbox{Client Credential Grant}[.47\linewidth]{
            \centering
            \missingfigure[figwidth=\textwidth]{Testing a text string}
            \label{fig:impl_grant}
        }
    }
    \caption{Caption}
    \label{fig:auth_impl_grant}
\end{figure}

\end{document}
| improve this answer | | | | |
  • I am using subfig because springers llncs and subcaption are not compatible – Silence and I Mar 19 '19 at 10:01
  • @SilenceandI. Have you tried using \captionsetup{compatibility=false}? – Peiffap Mar 19 '19 at 10:03
  • not yet, didn't know this exists – Silence and I Mar 19 '19 at 10:03
  • @SilenceandI. Tell me if it works, I will update my answer in case it does. – Peiffap Mar 19 '19 at 10:07
  • thank you very much - I added to my question the changes I made to your suggestion to get a properly formated version of it :) - feel free to update your answer – Silence and I Mar 19 '19 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.