1

I am trying to compile this code in LaTeX but it shows errors such as

alignment tab character $ has been changed to cr.

This is bit of my code where errors arise.

Can somebody help me to figure-out how to resolve this problem?

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}
\usepackage{amsfonts}
\usepackage{physics}
\usepackage[skins]{tcolorbox}
\usepackage{slashed}

\newcommand{\ms}{\medspace}
\newcommand{\I}{\mathbb{I}}%for identity matrix
\renewcommand{\l}{\left(}
\renewcommand{\r}{\right)}
\renewcommand{\a}{\alpha}
\newcommand{\p}{\hat{\slashed{P}}}
\newcommand{\s}{\sigma}
\renewcommand{\P}{\hat{P}}
\newcommand{\A}{\hat{A}}


\begin{document}    

\begin{multline}
    (p_0+\hat{p}_x)\qty[u_1(z)e^{\frac{i}{\hbar}xp_x}\qty(Ae^{\frac{i}{\hbar}yp_y}+A'e^{-\frac{i}{\hbar}yp_y})] & + i\hat{p}_y\qty[u_1(z) e^{\frac{i}{\hbar}xp_x}\qty(Ae^{\frac{i}{\hbar}yp_y}+A'e^{-\frac{i}{\hbar}yp_y} )]& =\ms\xi\qty[\ms u_2(z)e^{\frac{i}{\hbar}xp_x}\qty(Ae^{\frac{i}{\hbar}yp_y} + A'e^{-\frac{i}{\hbar}yp_y})]&\quad-i\hbar\partial_z\qty[u_2(z)e^{\frac{i}{\hbar}xp_x}\qty(Ae^{\frac{i}{\hbar}yp_y}+A'e^{-\frac{i}{\hbar}yp_y})] 
\end{multline}



\end{document}
  • 4
    Just like your error message says. There is at least one & where it doesn't belong. I guess multiline doesn't accept & in the contents. – Skillmon Apr 10 '18 at 10:06
  • 1
    Welcome to TeX SX! Maybe you want an align ennvironment, or aligned nested in equation if you want a single equation number. – Bernard Apr 10 '18 at 10:10
  • 1
    Unrelated to your question, but noted...While you may think at first that creating a bunch of one-letter macros saves you time, in the long run you will probably regret it: 1) it overwrites other useful macros in some cases, and 2) the non-descriptive nature of a 1-letter macro makes it very unreadable, when you revisit the code at a later time. – Steven B. Segletes Apr 10 '18 at 10:44
  • note that redefining \a breaks almost all accent commands in tabbing, redefining \r breaks any letter with a ring accent, redefining \l breaks the slashed l letter, so even if you have no accented letters in your main text beware names in bibliographies etc, it is not usually a good idea to redefine those commands – David Carlisle Apr 10 '18 at 11:40
  • like other multiline display environments, multline requires that the lines be separated by \\ . (that's the equivalent of \cr, which was inserted by (la)tex.) you haven't indicated where the lines should end. you might benefit from looking at the amsmath user's guide -- texdoc amsldoc. – barbara beeton Apr 10 '18 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.