![阵列和对齐](https://linux22.com/image/404067/%E9%98%B5%E5%88%97%E5%92%8C%E5%AF%B9%E9%BD%90.png)
我正在尝试显示数组中的值列表。顶行没问题,但当我添加另一个值时,一切都乱了套。我该如何解决这个问题?基本上,我希望所有值都等距分布,并且任何不适合同一行的值都以相同的对齐方式放在下一行。谢谢!
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{parskip}
\begin{document}
\centerline{Question 2}
$x = \begin{array}{ccc}
-1.5 & -0.5 & -0.804163391778384
\end{array}$
iteration =
\hspace{8mm}1
$x = \begin{array}{ccc}
-1.5 & -0.5 & -0.804163391778384
\\-0.805017312865838
\end{array}$
iteration =
\hspace{8mm}2
\end{document}
答案1
不清楚你喜欢什么。我怀疑你正在寻找以下内容:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{parskip}
\begin{document}
\centerline{Question 2}
$x = \begin{array}{ccc}
-1.5 & -0.5 & -0.804163391778384
\end{array}$
iteration =
\hspace{8mm}1
$x = \begin{array}[t]{ccc}
-1.5 & -0.5 & -0.804163391778384 \\
-0.805017312865838 & &
\end{array}$
iteration =
\hspace{8mm}2
\end{document}
或者您可能希望拥有以下内容:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{parskip}
\begin{document}
\centerline{Question 2}
$x = -1.5 - 0.5 - 0.804163391778384$
iteration \hspace{8mm}1:
$\begin{aligned}
x & = -1.5 - 0.5 - 0.804163391778384 \\
& = -0.805017312865838
\end{aligned}$
iteration \hspace{8mm}2:
\end{document}
根据您添加的有关信息,您似乎希望拥有:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\centerline{Question 2}
$x = \begin{array}{@{} *{3}{>{$}p{9em}<{$}} }
-1.5 & -0.5 & -0.804163391778384
\end{array}$
iteration = \hspace{8mm}1
$x = \begin{array}[t]{@{} *{3}{>{$}p{9em}<{$}} }
-1.5 & -0.5 & -0.804163391778384 \\
-0.805017312865838 & &
\end{array}$
iteration = \hspace{8mm}2
\end{document}