方程环境标签和断线之间不兼容

方程环境标签和断线之间不兼容

我正在尝试使用环境\tag内部equation*和线路制动\\,但是收到以下错误:

! 软件包 amsmath 错误:\tag 此处不允许

我已经检查过了amsmath 错误分裂方程但似乎都无法解决我的不兼容问题。

这是我的 MWE:

\documentclass[letterpaper,11pt]{article}
\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt
]{biblatex}
\addbibresource{peers.bib}
\usepackage{mathtools,cancel}
\usepackage{venndiagram}
\usepackage[export]{adjustbox} % also loads graphicx
\usepackage{tabularx} % extra features for tabular environment
\usepackage{graphicx} % takes care of graphic including machinery
\usepackage[margin=1in,letterpaper]{geometry} % decreases margins
\usepackage[final]{hyperref} % adds hyper links inside the generated pdf file
\hypersetup{
    colorlinks=true,       % false: boxed links; true: colored links
    linkcolor=blue,        % color of internal links
    citecolor=blue,        % color of links to bibliography
    filecolor=magenta,     % color of file links
    urlcolor=blue         
}


\newcommand{\eqn}{\[
    \stcomp{(A \cup B)} = \stcomp{A} \cap \stcomp{B}
\]}

%+++++++++++++++++++++++++++++++++++++++
\begin{document}

\begin{equation*}
 \begin{aligned}
    \tag{Final Portfolio Variance}
 \sigma_{p}^{2} = \dfrac{1}{n^{\color{red}\cancel{2}}}\mathbin{\color{red} \cancel{n} \Bar{Var}} + \dfrac{1}{n^{\color{blue}\cancel{2}}}\mathbin{\color{blue}\cancel{n}(n-1) \Bar{Cov}} \\
 =  \underbrace{\dfrac{1}{n}\Bar{Var}}_\text{$\rightarrow 0$} + \underbrace{(1-\dfrac{1}{n})\Bar{Cov}}_\text{$\rightarrow$ $\Bar{Cov}$} 
    \label{eqn:final_portfolio_variance}
  \end{aligned}
 \end{equation*}

 \end{document}

答案1

您需要&在 align* 或 aligned 中的某处包含它。

\documentclass[letterpaper,11pt]{article}
\usepackage[
backend=biber,
style=alphabetic,
sorting=ynt
]{biblatex}
\addbibresource{peers.bib}
\usepackage{mathtools,cancel}
\usepackage{venndiagram}
\usepackage[export]{adjustbox} % also loads graphicx
\usepackage{tabularx} % extra features for tabular environment
\usepackage{graphicx} % takes care of graphic including machinery
\usepackage[margin=1in,letterpaper]{geometry} % decreases margins
\usepackage[final]{hyperref} % adds hyper links inside the generated pdf file
\hypersetup{
    colorlinks=true,       % false: boxed links; true: colored links
    linkcolor=blue,        % color of internal links
    citecolor=blue,        % color of links to bibliography
    filecolor=magenta,     % color of file links
    urlcolor=blue         
}


\newcommand{\eqn}{\[
    \stcomp{(A \cup B)} = \stcomp{A} \cap \stcomp{B}
\]}

%+++++++++++++++++++++++++++++++++++++++
\begin{document}

\begin{align*}
 \tag{Final Portfolio Variance}
 \sigma_{p}^{2} &= \dfrac{1}{n^{\color{red}\cancel{2}}}\mathbin{\color{red} \cancel{n} \Bar{Var}} + \dfrac{1}{n^{\color{blue}\cancel{2}}}\mathbin{\color{blue}\cancel{n}(n-1) \Bar{Cov}} \\
 &=  \underbrace{\dfrac{1}{n}\Bar{Var}}_\text{$\rightarrow 0$} + \underbrace{(1-\dfrac{1}{n})\Bar{Cov}}_\text{$\rightarrow$ $\Bar{Cov}$} 
    \label{eqn:final_portfolio_variance}
 \end{align*}

 \end{document}

相关内容