0

I am trying to use a \tag inside the equation* environment and line brake \\, however, I receive the following error:

! Package amsmath Error: \tag not allowed here

I have already checked amsmath Error and split equation but none of them seem to solve my incompatibility.

Here is my 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}
3
  • You can use align instead of equation if you want more than one \tag or line. You can move the \tag outside aligned, but it will be centered (one \tag per equation). Feb 24, 2022 at 21:39
  • Unfortunately, neither of your suggestions solved the problem, but thank you anyway!
    – unmark1
    Feb 24, 2022 at 21:53
  • Unrelated, but note that your use of \text is completely wrong here, and should just be _{\rightarrow 0}, math mode nor \text has any business there. Similar on the other one
    – daleif
    Feb 24, 2022 at 21:55

1 Answer 1

2

You need to include & somewhere in either align* or 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}
2
  • Yes, it solved the problem! Thank you. Can you explain why not using the equation environment solved the problem, please? Thank you very much!
    – unmark1
    Feb 25, 2022 at 14:42
  • If you use \fbox{$\begin{aligned} ... \end{aligned}$} you will see there is no room inside aligned for the tag. Feb 26, 2022 at 4:10

You must log in to answer this question.

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