1

Below code is working fine.

\begin{eqnarray*}
\begin{split}
    (U\ket{v},U\ket{w}) & = (\ket{v},\ket{w}) \\
    || \ket{Uv} || & = || \ket{v} ||
\end{split}
\end{eqnarray*}

But if I define equation environment in macros, then it is giving error that "Split can't work in math mode".

In preamble,

\newcommand{\benn}{\begin{equation*}}
\newcommand{\eenn}{\end{equation*}}

Using it inside,

\benn
\begin{split}
        (U\ket{v},U\ket{w}) & = (\ket{v},\ket{w}) \\
        || \ket{Uv} || & = || \ket{v} ||
\end{split}
\eenn

Edit: Minimal not working example

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float}
\usepackage[margin=0.8in]{geometry}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{gensymb}

\usepackage{amsthm}
\usepackage{braket}



\newcommand{\beann}{\begin{eqnarray*}}
\newcommand{\eeann}{\end{eqnarray*}}

\begin{document}

    \beann
        \begin{split}
            (U\ket{v},U\ket{w}) & = (\ket{v},\ket{w}) \\
            || \ket{Uv} || & = || \ket{v} ||
        \end{split}
    \eeann
\end{document}
10
  • Welcome to TeX.SE: can you see this link please? tex.stackexchange.com/questions/155165/…
    – Sebastiano
    Aug 15, 2018 at 10:47
  • Ohh sorry, I was not able to find it. Thanks!
    – MeetR
    Aug 15, 2018 at 10:53
  • Don't worry. Almost two years ago, I was unable to find it myself. :-)
    – Sebastiano
    Aug 15, 2018 at 10:54
  • 1
    I can't completely agree with @Sebastiano's link. That seems to be a different problem (hidden &). As a matter of fact, the code you posted works perfectly fine for me. I have suspects about what you are doing wrong, but you should post a a full minimal working example which reproduces the issue, starting with \documentclass{...} and ending with \end{document}.
    – campa
    Aug 15, 2018 at 10:57
  • 2
    Your MWE works for me. Aug 15, 2018 at 11:09

1 Answer 1

5

Please note: in the future please give a MWE and the exact error/warning. In your question you say the compiler

is giving error that "Split can't work in math mode".

while running the code gives the warning

Package amsmath Warning: Cannot use `split' here;
(amsmath)                trying to recover with `aligned' on input line 19.

For people trying to figure out what is going on there is quite a difference :-)

Now to the issue: the amsmath user's guide states

The split environment is designed to serve as the entire body of an equation, or an entire line of an align or gather environment. There cannot be any printed material before or after it within the same enclosing structure.

But eqnarray (which shouldn't be used anyway when amsmath is loaded, see eqnarray vs align) kind of does that, so that's why this is failing.

In this particular case, I see no reason to enclose split within an environment providing aligning points. You can use align* (without split), or \[ ... \]

\documentclass{article}

\usepackage{mathtools} % loads amsmath
\DeclarePairedDelimiter{\norm}{\Vert}{\Vert}
\usepackage{amssymb}
\usepackage{gensymb}
\usepackage{braket}

\begin{document}

Either
\begin{align*}
(U\ket{v},U\ket{w}) & = (\ket{v},\ket{w}) \\
\norm{\ket{Uv}} & = \norm{\ket{v}}
\end{align*}
or
\[
\begin{split}
(U\ket{v},U\ket{w}) & = (\ket{v},\ket{w}) \\
\norm{\ket{Uv}} & = \norm{\ket{v}}
\end{split}
\]
\end{document}
  • I removed a couple of packages irrelevant for the MWE
  • I loaded mathtools (which loads amsmath) and defined a macro \norm
2
  • Sorry for late reply. What is \[ ... \] ? Does it denote math mode?
    – MeetR
    Aug 19, 2018 at 9:45
  • Once you load amsmath it's the same as equation*.
    – campa
    Aug 19, 2018 at 13:03

You must log in to answer this question.

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