在同一方程中使用 align 和 \crefrange 时出错

在同一方程中使用 align 和 \crefrange 时出错

我是 Latex 家族的新成员,需要一些帮助。

\crefrange当我在环境中使用时,我收到错误列表align

例如

\usepackage{amsmath}
\usepackage[hidelinks]{hyperref}
\usepackage[capitalise]{cleveref}

\begin{align}
\min &\left(
\underbrace{\sum\limits_{t \in T} 
\left(\mathcal{Q}^{+}_{t} \pi^{+}_{t} - \mathcal{Q}^{-}_{t} \pi^{-}_{t} \right) 
\Delta t}_\text{electricity cost} 
+ \underbrace{\sum\limits_{t \in T} \sum\limits_{b \in B} 
\partial_{(t,b)}}_\text{degradation penalty} \right) 
\label{base1} \\
\st \notag \\
&\mathcal{Q}^{+}_{t} - \mathcal{Q}^{-}_{t} = \mathcal{P}^{L}_{t} 
+ \sum\limits_{b \in B} \mathcal{P}^{c}_{(t,b)} 
- \mathcal{P}^{K}_{t} \label{base2} \\
&\Crefrange{eq_Ch4_soc1}{eq_Ch4_deg2}, 
 \crefrange{eq_Ch4_opt4}{eq_Ch4_opt6} \notag \\
&\Crefrange{eq_Ch4_power3}{eq_Ch4_power5} \label{base3}
\end{align}

当我注释掉(排除)文章的这一部分时,LaTeX 会毫无错误地处理整篇文章。

我在文章的其他位置确实有方程式,但是它没有遇到任何错误,因为这些方程式中align没有这些方程式。\crefrange

以下是我运行代码时出现的错误列表:

Use of \refstepcounter@optarg doesn't match its definition. \end{align}
Missing \endcsname inserted. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Missing \endcsname inserted. \end{align}
Missing \endcsname inserted. \end{align}
Argument of \@firstoftwo has an extra }. \end{align}
Paragraph ended before \@firstoftwo was complete. \end{align}
Use of \@@cref@getlabel doesn't match its definition. \end{align}
Missing \endcsname inserted. \end{align}
Missing \endcsname inserted. \end{align}
Missing \endcsname inserted. \end{align}
Undefined control sequence. \end{align}
Argument of \@firstoftwo has an extra }. \end{align}
Paragraph ended before \@firstoftwo was complete. \end{align}
Use of \@@cref@gettype doesn't match its definition. \end{align}
Argument of \@@cref@gettype has an extra }. \end{align}
Paragraph ended before \@@cref@gettype was complete. \end{align}
Missing \endcsname inserted. \end{align}
Undefined control sequence. \end{align}
Argument of \@crefrangenostar has an extra }. \end{align}
Paragraph ended before \@crefrangenostar was complete. \end{align}
Argument of \@crefrangenostar has an extra }. \end{align}
Paragraph ended before \@crefrangenostar was complete. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Missing \endcsname inserted. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Argument of \label@noarg has an extra }. \end{align}
Paragraph ended before \label@noarg was complete. \end{align}
Undefined control sequence. \end{align}
Extra \else. \end{align}
Missing \endcsname inserted. \end{align}
Missing \endcsname inserted. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Argument of \@firstoftwo has an extra }. \end{align}
Paragraph ended before \@firstoftwo was complete. \end{align}
Use of \@@cref@gettype doesn't match its definition. \end{align}
Missing \endcsname inserted. \end{align}
Undefined control sequence. \end{align}
Argument of \@crefrangenostar has an extra }. \end{align}
Paragraph ended before \@crefrangenostar was complete. \end{align}
Argument of \@crefrangenostar has an extra }. \end{align}
Paragraph ended before \@crefrangenostar was complete. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Missing \endcsname inserted. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}
Argument of \cref@stack@to@list has an extra }. \end{align}
Paragraph ended before \cref@stack@to@list was complete. \end{align}
Undefined control sequence. \end{align}

答案1

我不知道多行方程中的\crefrange和指令起什么作用。我确信交叉引用几乎总是在文本模式下进行,而不是在数学模式下。\Crefrange

我还将注释掉(或删除)包含未定义的宏的行st

单独的评论:我会使用\biggl(\biggr)不是 \left(\right,调整第一行大括号的大小。哦,这些\limits指令除了造成代码混乱外,什么也没做。

在此处输入图片描述

\documentclass{article}
\usepackage{mathtools}
\usepackage[hidelinks]{hyperref}
\usepackage[capitalise]{cleveref}
\begin{document}
\begin{align}
    \min &\biggl(\,
    \underbrace{\sum_{t\in T} (\mathcal{Q}^{+}_t \pi^{+}_t 
         - \mathcal{Q}^{-}_t \pi^{-}_t ) \Delta t}
         _{\text{electricity cost}}
  + \underbrace{\sum_{t\in T} \sum_{b\in B} \partial_{(t,b)}}
         _{\mathclap{\text{degradation penalty}}}\!
    \biggr) \label{base1} \\[1ex]
%    \st \notag \\  % how is `\st` defined?
    &\mathcal{Q}^{+}_t - \mathcal{Q}^{-}_t 
      = \mathcal{P}^{L}_t + \sum_{b\in B} \mathcal{P}^{c}_{(t,b)} 
       -\mathcal{P}^{K}_t \label{base2} 
%    \\
%    &\Crefrange{eq_Ch4_soc1}{eq_Ch4_deg2}, \crefrange{eq_Ch4_opt4}{eq_Ch4_opt6} \notag \\
%    &\Crefrange{eq_Ch4_power3}{eq_Ch4_power5} \label{base3}
\end{align}
\end{document}

相关内容