Elsevier cas-dc 问题:minipage 和“LaTeX 错误:命令 \bibsep 已定义”

Elsevier cas-dc 问题:minipage 和“LaTeX 错误:命令 \bibsep 已定义”

在这个问题中(见老问题) 您谈到了如何在 Elsevier cas-dc 类中使用 minipage 对齐两个图形。我遇到了同样的问题。我尝试添加此补丁,现在代码可以正常工作了!但是,这会导致新的错误:“LaTeX 错误:命令 \bibsep 已定义”...我该如何修复此问题?谢谢

这是我的代码的一部分(出于隐私原因我不能放更多内容但至少出现了错误):

\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

我对另一个问题的回答无条件地做了,\newlength\bibsep因为当我查看它时,该类缺少它。 可能是你得到的版本没有这个缺陷(但在我的记忆中它有相当多的缺陷,我怀疑每一个都得到了修复)。

如果您正在加载这样的包,natbib也可能会提供一个\bibsep,并且您可能会因此收到错误。

但是,为了(希望如此,如果没有 MWE 来显示您的问题所在,我无法保证任何事情)修复此问题,您可以检查是否\bibsep已定义,如果没有定义,则执行定义。我已将其放入钩子中,begindocument/before它应该可以工作(除非您在此之后加载了一些包,所以不能保证……):

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

相关内容