latex公式如何对齐

2025-10-10 19:27:47

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)等。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢