![将 vdot 与方程组中的项对齐](https://linux22.com/image/292474/%E5%B0%86%20vdot%20%E4%B8%8E%E6%96%B9%E7%A8%8B%E7%BB%84%E4%B8%AD%E7%9A%84%E9%A1%B9%E5%AF%B9%E9%BD%90.png)
我正在尝试编写一个如下所示的线性方程组:
A_{11}x_1 + A_{12}x_2 + \cdots + A_{1n}x_n = y_1
A_{21}x_1 + A_{22}x_2 + \cdots + A_{2n}x_n = y_2
\vdots \vdots \vdots \vdots
A_{m1}x_1 + A_{m2}x_2 + \cdots + A_{mn}x_n = y_m
其中 vdot 位于项的中心,而不是等号的中心。这是我的尝试:
\documentclass{report}
\usepackage{amsmath}
\begin{document}
\begin{align*}
&A_{11}x_1& + &A_{12}x_2& + \cdots + &A_{1n}x_n& = &y_1& \\
&A_{21}x_1& + &A_{22}x_2& + \cdots + &A_{2n}x_n& = &y_2& \\
&\vdots& &\vdots& &\vdots& &\vdots& \\
&A_{m1}x_1& + &A_{m2}x_2& + \cdots + &A_{mn}x_n& = &y_m& \\
\end{align*}
\end{document}
有人有一个优雅的解决方案吗?
编辑。这是第二次尝试,使用更适合的array
环境。看起来好多了,但仍然不自然。
\documentclass{report}
\begin{document}
\[\begin{array}{ccccccccc}
A_{11}x_1 & + & A_{12}x_1 & + & \cdots & + & A_{1n}x_n & = & y_1 \\
A_{21}x_1 & + & A_{22}x_2 & + & \cdots & + & A_{2n}x_n & = & y_2 \\
\vdots & & \vdots & & & & \vdots & & \vdots \\
A_{m1}x_1 & + & A_{m2}x_2 & + & \cdots & + & A_{mn}x_n & = & y_m \\
\end{array}\]
\end{document}
有没有什么办法可以让 vdot 像这样对齐,但又使方程式看起来正常?
答案1
我建议做如下修改:
\documentclass{report}
\usepackage{array}
\begin{document}
\[\begin{array}{*{9}{@{}c@{}}}
A_{11}x_1 & {}+{} & A_{12}x_1 &{}+{} & \cdots & {}+{} & A_{1n}x_n & {}\mathrel{=}{} & y_1 \\
A_{21}x_1 & + & A_{22}x_2 & + & \cdots & + & A_{2n}x_n & = & y_2 \\
\vdots & & \vdots & & & & \vdots & & \vdots \\
A_{m1}x_1 & + & A_{m2}x_2 & + & \cdots & + & A_{mn}x_n & = & y_m \\
\end{array}\]
\end{document}
答案2
我建议您使用 a\makebox
来居中\vdots
并使用alignat
环境来执行多个对齐点:
代码:
\documentclass{report}
\usepackage{amsmath}
\usepackage{calc}
\newcommand*{\MyVdots}[1][$A_{22}x_n$]{\makebox[\widthof{#1}]{$\vdots$}}%
\newcommand*{\Ph}{\hphantom{{}+{}}}%
\begin{document}
\begin{alignat*}{5}
&A_{11}x_1 &&{}+ A_{12}x_2 &&{}+ \cdots &&{}+ A_{1n}x_n && = y_1 \\
&A_{21}x_1 &&{}+ A_{22}x_2 &&{}+ \cdots &&{}+ A_{2n}x_n && = y_2 \\
&\MyVdots &&\Ph \MyVdots && &&\Ph \MyVdots &&\Ph \MyVdots[$y_1$] \\
&A_{m1}x_1 &&{}+ A_{m2}x_2 &&{}+ \cdots &&{}+ A_{mn}x_n && = y_m \\
\end{alignat*}
\end{document}
答案3
这里有两个 TABstack,一个周围的空间较小\vdots
,另一个周围的空间较大。
\documentclass{report}
\usepackage{tabstackengine}
\stackMath
\begin{document}
\[\TABbinary
\let\svvdots\vdots\def\vdots{\protect\raisebox{-3pt}{$\svvdots$}}
\tabbedCenterstack{
A_{11}x_1 & + & A_{12}x_1 & + & \cdots & + & A_{1n}x_n & = & y_1 \\
A_{21}x_1 & + & A_{22}x_2 & + & \cdots & + & A_{2n}x_n & = & y_2 \\
\vdots & & \vdots & & & & \vdots & & \vdots \\
A_{m1}x_1 & + & A_{m2}x_2 & + & \cdots & + & A_{mn}x_n & = & y_m \\
}\]
\[\TABbinary
\let\svvdots\vdots\def\vdots{\protect\raisebox{3pt}{$\svvdots$}}
\tabbedShortstack{
A_{11}x_1 & + & A_{12}x_1 & + & \cdots & + & A_{1n}x_n & = & y_1 \\
A_{21}x_1 & + & A_{22}x_2 & + & \cdots & + & A_{2n}x_n & = & y_2 \\
\vdots & & \vdots & & & & \vdots & & \vdots \\
A_{m1}x_1 & + & A_{m2}x_2 & + & \cdots & + & A_{mn}x_n & = & y_m \\
}\]
\end{document}