1

I want to place a subcaption below each figure (five figures on a page), such as the following figures. I have done it with the help of this link, but there is a problem with \floatbox. How to solve it?

enter image description here

\documentclass[review]{elsarticle}
\graphicspath{ {./figures/} }
\usepackage{hyperref}
%\usepackage{float}
\usepackage{verbatim} %comments
\usepackage{apalike}
%\restylefloat{figure}
%\floatstyle{plaintop}
%\restylefloat{table}

\usepackage{lipsum,capt-of,graphicx} \usepackage{geometry}

\usepackage{natbib} \let\printorcid\relax \usepackage[wby]{callouts} \usepackage{ragged2e} \usepackage{setspace}

\usepackage[labelfont=bf,justification=raggedright,singlelinecheck=false, font={footnotesize}]{caption} \captionsetup[figure]{name=Fig. ,labelsep=period, justification=justified, singlelinecheck=off} \captionsetup[table]{labelsep=newline,font=footnotesize, justification=justified, singlelinecheck=off}%,skip=0pt,belowskip=0pt}

\usepackage{subcaption} \usepackage{setspace}

\usepackage{etoolbox} \AtBeginEnvironment{table}{\sffamily} \usepackage{booktabs,siunitx, multirow} \sisetup{table-format=1.4, tight-spacing=true, separate-uncertainty}

\sisetup{ output-exponent-marker = \text{e}, exponent-product={}, retain-explicit-plus, input-open-uncertainty = , input-close-uncertainty = , table-align-text-pre = false, table-align-text-post = false, round-mode=places, round-precision=2, table-space-text-pre = (, table-space-text-post = ), }

\usepackage{amsmath} \usepackage{adjustbox} \usepackage{floatrow} \floatsetup[table]{capposition=top} \floatsetup[table]{captionskip=0.1pt} \floatsetup[subfigure]{objectset=centering}

\usepackage{array, cellspace} \setlength\cellspacetoplimit{3pt} \setlength\cellspacebottomlimit{3pt}

\usepackage{placeins}

\begin{document}

\begin{figure} \subfloat[]{\label{main:a}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}\quad \subfloat[]{\label{main:b}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}

\medskip

\subfloat[]{\label{main:c}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}\quad \subfloat[]{\label{main:d}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}

\medskip

\floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,bottom},capbesidewidth=7.3cm}}]{figure} {\caption{Caption text}\label{fig:test}} \subfloat[]{\label{main:e}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}} \end{figure}

\end{document}

Error is here:

\floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,bottom},capbesidewidth=7.3cm}}]{figure}
{\caption{Caption text}\label{fig:test}}
\subfloat[]{\label{main:e}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}
\end{figure}

! Argument of \subcaption@subfloat@ has an extra }. <inserted text> \par l.75 \subfloat []{\label{main:e}\includegraphics[width=.48\textwidth,height=5...

?

Ellie
  • 242

2 Answers2

1

enter image description here

\documentclass[review]{elsarticle}
\graphicspath{ {./figures/} }
\usepackage{hyperref}
%\usepackage{float}
\usepackage{verbatim} %comments
\usepackage{apalike}
%\restylefloat{figure}
%\floatstyle{plaintop}
%\restylefloat{table}

\usepackage{lipsum,capt-of,graphicx} \usepackage{geometry}

\usepackage{natbib} \let\printorcid\relax \usepackage[wby]{callouts} \usepackage{ragged2e} \usepackage{setspace}

\usepackage[labelfont=bf,justification=raggedright,singlelinecheck=false, font={footnotesize}]{caption} \captionsetup[figure]{name=Fig. ,labelsep=period, justification=justified, singlelinecheck=off} \captionsetup[table]{labelsep=newline,font=footnotesize, justification=justified, singlelinecheck=off}%,skip=0pt,belowskip=0pt}

\usepackage{subcaption} \usepackage{setspace}

\usepackage{etoolbox} \AtBeginEnvironment{table}{\sffamily} \usepackage{booktabs,siunitx, multirow} \sisetup{table-format=1.4, tight-spacing=true, separate-uncertainty}

\sisetup{ output-exponent-marker = \text{e}, exponent-product={}, retain-explicit-plus, input-open-uncertainty = , input-close-uncertainty = , table-align-text-pre = false, table-align-text-post = false, round-mode=places, round-precision=2, table-space-text-pre = (, table-space-text-post = ), }

\usepackage{amsmath} \usepackage{adjustbox} \usepackage{floatrow} \floatsetup[table]{capposition=top} \floatsetup[table]{captionskip=0.1pt} \floatsetup[subfigure]{objectset=centering}

\usepackage{array, cellspace} \setlength\cellspacetoplimit{3pt} \setlength\cellspacebottomlimit{3pt}

\usepackage{placeins}

\begin{document}

\begin{figure} \subfloat[]{\label{main:a}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}\quad \subfloat[]{\label{main:b}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}

\medskip

\subfloat[]{\label{main:c}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}\quad \subfloat[]{\label{main:d}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}

\medskip

\subfloat[]\par \floatbox[{\capbeside\thisfloatsetup{capbesideposition={right,bottom},capbesidewidth=7.3cm}}]{figure} {\caption{Caption text}\label{fig:test}} {\label{main:e}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}} \end{figure}

\end{document}

Ellie
  • 242
1

If this is for publication, you need to check with elsearticle about changing the caption formats.

Here is a solution which does NOT use floatrow. I showed the last baseline to make it easier to adjust the vertical location of the caption.

\documentclass[review]{elsarticle}
\graphicspath{ {./figures/} }
\usepackage{hyperref}
%\usepackage{float}
\usepackage{verbatim} %comments
\usepackage{apalike}
%\restylefloat{figure}
%\floatstyle{plaintop}
%\restylefloat{table}

\usepackage{lipsum,capt-of,graphicx} \usepackage{geometry}

\usepackage{natbib} \let\printorcid\relax \usepackage[wby]{callouts} \usepackage{ragged2e} \usepackage{setspace}

\usepackage[labelfont=bf,justification=raggedright,singlelinecheck=false, font={footnotesize}]{caption} \captionsetup[figure]{name=Fig. ,labelsep=period, justification=justified, singlelinecheck=off} \captionsetup[table]{labelsep=newline,font=footnotesize, justification=justified, singlelinecheck=off}%,skip=0pt,belowskip=0pt}

\usepackage{subcaption} \usepackage{setspace}

\usepackage{etoolbox} \AtBeginEnvironment{table}{\sffamily} \usepackage{booktabs,siunitx, multirow} \sisetup{table-format=1.4, tight-spacing=true, separate-uncertainty}

\sisetup{ output-exponent-marker = \text{e}, exponent-product={}, retain-explicit-plus, input-open-uncertainty = , input-close-uncertainty = , table-align-text-pre = false, table-align-text-post = false, round-mode=places, round-precision=2, table-space-text-pre = (, table-space-text-post = ), }

\usepackage{amsmath} \usepackage{adjustbox} %\usepackage{floatrow} %\floatsetup[table]{capposition=top} %\floatsetup[table]{captionskip=0.1pt} %\floatsetup[subfigure]{objectset=centering}

\usepackage{array, cellspace} \setlength\cellspacetoplimit{3pt} \setlength\cellspacebottomlimit{3pt}

\usepackage{placeins}

\begin{document}

\begin{figure} \subfloat[]{\label{main:a}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}\quad \subfloat[]{\label{main:b}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}

\medskip

\subfloat[]{\label{main:c}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}\quad \subfloat[]{\label{main:d}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}

\medskip

\subfloat[]{\label{main:e}\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}\quad \begin{minipage}[t]{.48\textwidth} \caption[singlelinecheck=false]{Caption text}\label{fig:test} \end{minipage} \hfill\llap{\rule{\textwidth}{0.5pt}}% show baseline (remove) \end{figure}

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120