1

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*}

1
  • 1
    That class seems pretty broken, imho. The captions always use the \linewidth which was correct somewhere in the preamble...
    – Skillmon
    Dec 8, 2021 at 9:04

1 Answer 1

2

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

7
  • Thank you very much! I tried adding this patch, and now the side-by-side figure can work correctly.
    – Yu Chen
    Dec 8, 2021 at 9:18
  • @YuChen there is more than that wrong with the internals of the class and package (some things seem to be half added but then abandoned, etc., for instance the figure environment accepts an optional key=value list with a key cols, but that key effectively does nothing!), if you find a maintainer for this class you should send them a bug report, imho.
    – Skillmon
    Dec 8, 2021 at 9:24
  • I'll try to give them feedback on such errors. Thanks for the reminder.
    – Yu Chen
    Dec 8, 2021 at 9:50
  • Thank you so much, I had the same problem and now the code works correctly. However, this leads to a new error: "LaTeX Error: Command \bibsep already defined" ... How can I fix this?
    – Elisa
    Feb 18, 2023 at 9:49
  • @Elisa - Which TeX distribution do you employ, and when was it last updated? The reason I ask is that I am unable to replicate the issue you say you're encountering on my system (MacTeX2022 w/ all updates applied) and cas-dc version 2021/05/11, 2.3.
    – Mico
    Feb 18, 2023 at 11:46

You must log in to answer this question.

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