latex公式如何对齐

时间:2026-02-13 17:31:08

1、首先,给出演示素材,比如要写出如下的公式:

latex公式如何对齐

2、如上图所示公式,最为关键的是如何对齐等号,一种简单的方式就是利用&符号来对齐,在每个等号前添加&符号即可,代码如下:

A & =(x-y)(x+y) \\

   & =x*x+x*y-y*x-y*y\\

   & = x^2 - y^2

3、当然,对齐时需要设置特定格式或则说环境,需要添加如下语句说明:

\begin{aligned} % requires amsmath; align* for no eq. number

A & =(x-y)(x+y) \\

   & =x*x+x*y-y*x-y*y\\

   & = x^2 - y^2

\end{aligned}

4、所以完整latex代码如下所示:

\documentclass{article}

\usepackage{amssymb,amsmath}

\begin{document}

\begin{equation*}

\begin{aligned} % requires amsmath; align* for no eq. number

A & =(x-y)(x+y) \\

   & =x*x+x*y-y*x-y*y\\

   & = x^2 - y^2

\end{aligned}

\end{equation*}

\end{document}

latex公式如何对齐

5、需要注意的是,在打印预览时,需要选择合适的排版系统(如LaTex、XeTex)等。

© 2026 五度知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com