How to align these two expressions, one has one more number?
You have to remove the 1
from the \phantom
, since it shows up explicitly outside the \phantom
. I replace it with {}
placeholder.
\documentclass{article}
\begin{document}
\[\begin{array}{c}
(-(a-1)^2-1)x+(-(a-1)^2-1)\\
(-(a-1)^2-1)x+\phantom{(-(a-1)^2-{})}1
\end{array}\]
\end{document}
In response to a comment from the OP, I leave this also, to show what can be done when the \phantom
and residual term do not share common digits.
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[\begin{array}{c}
(-(a-1)^2-1)x+(-(a-1)^2-1)\\
(-(a-1)^2-1)x+\phantom{(-(a-1)^2-1)}\mathllap{5-4+2^2}
\end{array}\]
\end{document}
Add more alignment points:
\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\[
\begin{array}{@{} l @{}>{{}}c<{{}}@{} r @{}}
(-(a-1)^2-1)x &+& (-(a-1)^2-1)\\
(-(a-1)^2-1)x &+& 1
\end{array}
\]
\end{document}