2

I try to insert the caption on side of a figure (such as the following fig), but I couldn't set it. How to set it? I have also seen: link and link.

enter image description here

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

\usepackage{lipsum,capt-of,graphicx} \usepackage{geometry}% Just for this example %\usepackage[authoryear,longnamesfirst]{natbib} %\usepackage[authoryear]{natbib} %\usepackage[numbers]{natbib} \usepackage{natbib} \let\printorcid\relax \usepackage[wby]{callouts} %\usepackage{cite} \usepackage{ragged2e} \usepackage{setspace} %\usepackage{caption} %\usepackage[font={footnotesize},labelfont=bf]{caption} \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} %\setlength\abovecaptionskip{-5pt} %\setlength{\heavyrulewidth}{3\lightrulewidth} \usepackage{subcaption} \usepackage{setspace} %\renewcommand{\baselinestretch}{1.8}

%%%Author definitions

%%%

%\usepackage[flushleft]{threeparttable} %\renewcommand\TPTtagStyle{\textit} \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]{style=Plaintop}

%\setlength{\mathindent}{0pt}

%\makeatletter %@dblfpsep=20pt %\makeatother

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

\begin{document} \begin{figure}[htb] \centering \begin{tabular}{cc} \includegraphics[width=.4\textwidth]{example-image-a} & \includegraphics[width=.4\textwidth]{example-image-a}\ \includegraphics[width=.4\textwidth]{example-image-a} & \includegraphics[width=.4\textwidth]{example-image-a}\ \includegraphics[width=.4\textwidth]{example-image-a} &\multicolumn{1}{b{.4\linewidth}}{\caption{Caption text coming here at the last position}} \end{tabular} \end{figure}

\end{document}

Also, I have checked the following code, but an error has occurred:

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

Error:

   ! Package floatrow Error: Do not use float package with floatrow.
    (floatrow)                The latter will be skipped.

The problem is because of \usepackage{float} and \usepackage{floatrow}. While, I need to both of them: \usepackage{float} for caption of Tables and \usepackage{floatrow} for caption of figures. But, They are not compatible. How to solve it?

Ellie
  • 242
  • Like this? Ah, you already looked into it. What did not work from one of the answers to that question? – Oleg Lobachev Jun 10 '21 at 13:25
  • @Oleg Lobachev: I want to achieve the above fig. I have changed one of those suggestions for my five figures, but an error has occurred (I have updated my question). How to change code(s) in your suggestion link for my purpose? – Ellie Jun 10 '21 at 14:24

2 Answers2

2

By use of the adjustbox and tabularx packages you can get the following result:

enter image description here

\documentclass[review]{elsarticle}
\usepackage[labelfont=bf,
            justification=raggedright,
            singlelinecheck=false, 
            font={footnotesize, stretch=0.84}]{caption}
\usepackage[export]{adjustbox}
\usepackage{tabularx}

\begin{document} \begin{figure}[htb] \centering \setlength\tabcolsep{3pt} \adjustboxset{width=\linewidth, valign=m, margin=0pt 3pt 0pt 3pt} \begin{tabularx}{\linewidth}{@{} XX @{}} \adjustimage{}{example-image-a} & \adjustimage{}{example-image-a} \ \adjustimage{}{example-image-a} & \adjustimage{}{example-image-a} \ \adjustimage{}{example-image-a} & \parbox{\linewidth}{\caption{Caption text coming here at the last position}} \end{tabularx} \end{figure} \end{document}

Zarko
  • 296,517
  • @Ellie, ups, one close curly brace at \caption were lost. Corrected now. – Zarko Jun 10 '21 at 16:19
  • I have checked your code. Unfortunately, because of existence the \usepackage{float} in my code, the problem still exists. – Ellie Jun 10 '21 at 16:33
  • 2
    @Ellie, package float haven't any connection with my solution or influence on my solution. Errors, about which you report in question, clearly say, that you should not use float and floatrow packages in the same time in document. Remove one of them. BTW, why you need this package? For placement option H? I would avoid to use it as much as it is possible. It make unexpected troubles and problems ... – Zarko Jun 10 '21 at 17:42
0

Another solution:

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} {\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}\quad {\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}

\medskip

{\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}}\quad {\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}} {\includegraphics[width=.48\textwidth,height=5cm]{example-image-a}} \end{figure}

\end{document}

Ellie
  • 242