1

The following code aligns everything just the way I want -- and I can be much too picky -- except that the horizontal space to the last column is too wide. How can I make it narrower?

\begin{align*}
  \begin{pmatrix*}[r]
        1 & 2 &  -3 & 1 \\
        2 & 5 &  -8 & 4
    \end{pmatrix*}
    &\sim
    \begin{pmatrix*}[r]
        1 & 2 &  -3 & 1 \\
        0 & 1 &  -2 &  2
    \end{pmatrix*}
    && %\qquad
    \begin{matrix*}[l]
        \\
        \leftarrow -2r_1 + r_2 
    \end{matrix*} \\
    &\sim
    \begin{pmatrix*}[r]
        1 & 0 & 1 & -3 \\
        0 & 1 &  -2 &  2
    \end{pmatrix*}
    && %\qquad
    \begin{matrix*}[l]
        \leftarrow -2r_2 + r_1 \\
        \\
    \end{matrix*}
\end{align*}
3

You could use \begin{alignat*}{3} ... \end{alignat*} and replace the && %\qquad with & \quad:

enter image description here

Code:

\documentclass[preview,border=2mm]{standalone}
\usepackage{mathtools}% <-- includes amsmath

\begin{document}
Using \verb|align*|
\begin{align*}
  \begin{pmatrix*}[r]
        1 & 2 &  -3 & 1 \\
        2 & 5 &  -8 & 4
    \end{pmatrix*}
    &\sim
    \begin{pmatrix*}[r]
        1 & 2 &  -3 & 1 \\
        0 & 1 &  -2 &  2
    \end{pmatrix*}
    && %\qquad
    \begin{matrix*}[l]
        \\
        \leftarrow -2r_1 + r_2 
    \end{matrix*} \\
    &\sim
    \begin{pmatrix*}[r]
        1 & 0 & 1 & -3 \\
        0 & 1 &  -2 &  2
    \end{pmatrix*}
    && %\qquad
    \begin{matrix*}[l]
        \leftarrow -2r_2 + r_1 \\
        \\
    \end{matrix*}
\end{align*}
Using \verb|alignat*|
\begin{alignat*}{2}
  \begin{pmatrix*}[r]
        1 & 2 &  -3 & 1 \\
        2 & 5 &  -8 & 4
    \end{pmatrix*}
    &\sim
    \begin{pmatrix*}[r]
        1 & 2 &  -3 & 1 \\
        0 & 1 &  -2 &  2
    \end{pmatrix*}
    & \quad
    \begin{matrix*}[l]
        \\
        \leftarrow -2r_1 + r_2 
    \end{matrix*} \\
    &\sim
    \begin{pmatrix*}[r]
        1 & 0 & 1 & -3 \\
        0 & 1 &  -2 &  2
    \end{pmatrix*}
    & \quad
    \begin{matrix*}[l]
        \leftarrow -2r_2 + r_1 \\
        \\
    \end{matrix*}
\end{alignat*}
\end{document}
1

aligned allows several alignment points using the & symbol. If you need more space for the last column, use qquad or a similar hspace.

\documentclass[12pt,a4paper]{article}
\usepackage{mathtools}
\begin{document}

\[
\begin{aligned}
    \begin{pmatrix*}[r]
        1 & 2 &  -3 & 1 \\
        2 & 5 &  -8 & 4
    \end{pmatrix*}
    &\sim
    \begin{pmatrix*}[r]
        1 & 2 &  -3 & 1 \\
        0 & 1 &  -2 &  2
    \end{pmatrix*}
    & \leftarrow -2r_1 + r_2 \\
    &\sim
    \begin{pmatrix*}[r]
        1 & 0 & 1 & -3 \\
        0 & 1 &  -2 &  2
    \end{pmatrix*}
    & \leftarrow -2r_2 + r_1 
\end{aligned}
\]

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.