Latex编辑出现Misplaced alignment tab character &. 解决办法

Misplaced alignment tab character &.

在使用latex编辑论文排版,当想要输出分段函数时,出现报错Misplaced alignment tab character &. ,即原因是 对齐字符&放置错位,按照网上给的latex输出分段函数代码总是报错,就是如下这段:

\begin{equation}
f(x)=
\begin{cases}
0& \text{x=0}\\
1& \text{x!=0}
\end{cases}
\end{equation}

解决办法

在latex编辑器开头加入宏包,可能是少了宏命令导致 & 对齐符不能正常工作。
在开头处加入该包即可使得 & 正常工作。

% In your preamble (before \begin{document})
\usepackage{amsmath}

参考链接

Overleaf-Misplaced alignment tab character &

你可能感兴趣的:(latex)