0

In this question ( see Old question ) you talked about how to line up two figures with minipage in Elsevier cas-dc class. I had the same problem. I tried adding this patch, and now the code works correctly! However, this leads to a new error: "LaTeX Error: Command \bibsep already defined" ... How can I fix this? Thank you

This is a part of my code (I cannot put more for privacy reasons but at least the error appears):

\documentclass[a4paper,fleqn]{cas-dc}

\AddToHook{begindocument/before}{\ifdefined\bibsep\else\newlength\bibsep\fi} % class might be 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{natbib}

\usepackage{duckuments}


% If the frontmatter runs over more than one page
% use the longmktitle option.

%\documentclass[a4paper,fleqn,longmktitle]{cas-dc}

%\usepackage[numbers]{natbib}
%\usepackage[authoryear]{natbib}
\usepackage[authoryear,longnamesfirst]{natbib}
\usepackage{subcaption}

%%%Author macros
\def\tsc#1{\csdef{#1}{\textsc{\lowercase{#1}}\xspace}}
\tsc{WGM}
\tsc{QE}
%%%
\begin{document}
\let\WriteBookmarks\relax
\def\floatpagepagefraction{1}
\def\textpagefraction{.001}

% Short title
\shorttitle{...}    

% Short author
\shortauthors{...}  

% Main title of the paper
\title [mode = title]{....}

% Title footnote mark
% eg: \tnotemark[1]
\tnotemark[] 


% First author
%
% Options: Use if required
% eg: \author[1,3]{Author Name}[type=editor,
%       style=chinese,
%       auid=000,
%       bioid=1,
%       prefix=Sir,
%       orcid=0000-0000-0000-0000,
%       facebook=<facebook id>,
%       twitter=<twitter id>,
%       linkedin=<linkedin id>,
%       gplus=<gplus id>]

\author[1]{...}[]

% Corresponding author indication
\cormark[1]

% Footnote of the first author
\fnmark[]

% Email id of the first author
\ead{...}

% Address/affiliation
\affiliation[a]{
organization={University}}

\author[1]{...}[
]

% Footnote of the second author
\fnmark[]

% Corresponding author text
\cortext[1]{Corresponding author}



% For a title note without a number/mark
%\nonumnote{}

% Here goes the abstract
\begin{abstract}
...
\end{abstract}

% Keywords
% Each keyword is seperated by \sep
\begin{keywords}
...
\end{keywords}

\maketitle
% Main text

\section*{Appendix A}
\label{appendixA}
\renewcommand{\thefigure}{A.\arabic{figure}}
\setcounter{figure}{0}

\begin{figure*}
\centering
\begin{minipage}[t]{0.43\textwidth}
\centering
\includegraphics[width=\textwidth]{Figure Appendix/imageA.4.png}
\caption{....}
\end{minipage}
\qquad
\begin{minipage}[t]{0.43\textwidth}
\centering
\includegraphics[width=\textwidth]{Figure Appendix/imageA.5.png}
\caption{....}
\end{minipage}
\end{figure*}
\end{document}
1
  • 1
    Welcome to TeX.SE. Please tell us which TeX distribution you employ and when it was last updated. The reason I ask is that on my system (MacOS 13.2.1; MacTeX 2022 with all updates applied; cas-dc document class version 2021/05/11, 2.3) I am not able to replicate the issue you say you've encountered when running the code in the answer you provided a link to.
    – Mico
    Commented Feb 18, 2023 at 11:50

1 Answer 1

1

My answer in to the other question unconditionally did a \newlength\bibsep as the class was missing that when I took a look at it. It might be that you got a version of it that doesn't have this flaw (but from my memory there were quite a few flaws in it, I doubt every one of those is fixed).

If you're loading a package like natbib that might provide a \bibsep as well and you might get an error because of that.

However, to (hopefully, I can't guarantee anything without an MWE showing where your problem is) fix this, you can check whether \bibsep is defined and if it isn't do the definition. I've put this into the begindocument/before hook where it should work (unless you got some packages loaded later than that, so no guarantee...):

\documentclass[]{cas-dc}

\AddToHook{begindocument/before}{\ifdefined\bibsep\else\newlength\bibsep\fi} % class might be 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

% just an example of a package defining `\bibsep`, `natbib` is not needed for the answer to work
\usepackage{natbib} % might be the culprit for you (poor package does nothing wrong)

% just some dummy contents for our MWE, not needed for the answer to work
\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}
5
  • Thank you, I tried your code. Now there is "LaTeX Error: Option clash for package natbib." I edited my question and I added my code in order to better explain. Thank you
    – Elisa
    Commented Feb 18, 2023 at 12:53
  • 2
    @Elisa you shouldn't change the question after it has already been answered, now this answer makes no sense. If there is an issue then ask in a comment here or post a new question please
    – JamesT
    Commented Feb 18, 2023 at 13:04
  • I wanted to show my code, and here in the comment I can't do that... I'm sorry but I'm new and I have not yet learned how to use this site (also I don't speak english very well)
    – Elisa
    Commented Feb 18, 2023 at 13:11
  • @Elisa that's fine, no harm done. Just remove the \usepackage{natbib} you added just because of my example above, you don't need to load it twice, it was just an example of why you could get your initial error about the already defined \bibsep (and hey, I've guessed correct). Also, you don't really need duckuments (that's just providing dummy contents for the MWE to produce a document with some text).
    – Skillmon
    Commented Feb 18, 2023 at 23:22
  • Thank you so much! I am learning and I make a lot of mistakes haha
    – Elisa
    Commented Feb 19, 2023 at 14:12

You must log in to answer this question.

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