Floats – Lining Up Two Images with Different Titles Side by Side in Elsevier cas-dc Class

double-sidedels-casfloats

I am using elsevier's template – cas-dc, and I would like to have two images with different titles side by side in a double-column.
But the captions don't appear directly below the image, one of the captions is in the middle of the whole article.

And there is an overfull error reported.

ps: I referred to answers with similar questions and did not get a solution.
Placing three figures side by side, each with its own caption

\begin{figure*}
    \begin{minipage}[t]{0.48\linewidth}
        \includegraphics[width=\linewidth]{figs/Fig1.pdf}
        \caption{Problems due to rivet aging}
        \label{fig-problemofrivet}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{0.48\linewidth}
        \includegraphics[width=\linewidth]{figs/Fig1.pdf}
        \caption{Example of rivet replacement by the bolt}
        \label{fig-rivetrepla}
    \end{minipage}
\end{figure*}

Best Answer

The class has some hard design flaws (contained in cas-common.sty). I'm not sure whether it's a good idea to mess with the code of it, but the following patch should do:

EDIT: since there might be problems with unconditionally defining \bibsep I've changed it to do that only if it isn't yet defined, and do that pretty late.

\documentclass[]{cas-dc}

\AddToHook{begindocument/before}{\ifdefined\bibsep\else\newlength\bibsep\fi} % class is broken...

\ExplSyntaxOn
\exp_args:NNno \exp_args:Nno \use:n { \cs_gset:Npn \__make_fig_caption:nn #1#2 }
  {
    \exp_after:wN \use_ii_i:nn \exp_after:wN
      { \__make_fig_caption:nn {#1} {#2} }
      { \dim_set:Nn \l_fig_width_dim \linewidth }
  }
\exp_args:NNno \exp_args:Nno \use:n { \cs_gset:Npn \__make_tbl_caption:nn #1#2 }
  {
    \exp_after:wN \use_ii_i:nn \exp_after:wN
      { \__make_tbl_caption:nn {#1} {#2} }
      { \dim_set:Nn \l_tbl_width_dim \linewidth }
  }
\ExplSyntaxOff

\usepackage{duckuments}

\begin{document}
\blindduck[all]
\begin{figure*}
  \begin{minipage}[t]{0.48\linewidth}
    \includegraphics[width=\linewidth]{example-image-duck}
    \caption{Problems due to rivet aging\label{fig-problemofrivet}}
  \end{minipage}
  \hfill
  \begin{minipage}[t]{0.48\linewidth}
    \includegraphics[width=\linewidth]{example-image-duck}
    \caption{Example of rivet replacement by the bolt\label{fig-rivetrepla}}
  \end{minipage}
\end{figure*}
\blindduck[all]
\end{document}

enter image description here

Related Question