1

I have to write a list of two matrix equations. They are almost identical, but the elements in one matrix are slightly larger than the other one, which makes it look badly.

\begin{align}
  \begin{pmatrix}
    -\id & \id \\
     \id & -\id \\
  \end{pmatrix}  u = 0 \\
  \begin{pmatrix}
    \id &   \id \\
     \id &  \id
  \end{pmatrix}  v = 0 
\end{align}

Is there a simple and elegant way to make the two matrices match size? I've found this, but it is a much complex case than mine. Is there something simpler?

1

I propose two versions, the second one is what I'd prefer.

The calc packages is necessary only for the first solution. As a general rule, never use align without alignment points.

\documentclass{article}
\usepackage{amsmath,calc}
\newcommand{\id}{\mathrm{id}}
\newcommand{\cid}{\makebox[\widthof{$-\id$}]{$\id$}}
\begin{document}
\begin{align}
\begin{pmatrix}
  -\id & \id \\
   \id & -\id \\
\end{pmatrix}  u &= 0 \\
\begin{pmatrix}
  \cid &  \cid \\
  \cid &  \cid
\end{pmatrix}  v &= 0 
\end{align}
A different version
\begin{gather}
\begin{pmatrix}
  -\id & \id \\
   \id & -\id \\
\end{pmatrix}  u = 0 \\
\begin{pmatrix}
  \id &  \id \\
  \id &  \id
\end{pmatrix}  v = 0 
\end{gather}

\end{document}

enter image description here

1

Here are two solutions, far from perfect. I use the variants of the matrix environments defined by mathtools, which allow to specify the alignment in a matrix and I modify the value of \arraycolsep when needed.

I also define a \nid math operator, which corrects the spacing between and id in -\id, which is bad.

\documentclass{article}
\usepackage{textcomp} \usepackage{mathtools}
\usepackage[showframe]{geometry}
\DeclareMathOperator{\id}{{id}}
\newcommand*\nid{\ensuremath{-{\id}}}%
\newcommand*\varnid{\ensuremath{\mskip-5mu-{\id}}}
\newcommand*\varid{\ensuremath{\mskip-5mu\phantom{-}{\id}}}%

\begin{document}

\begin{align}
  \begin{pmatrix*}[r]
  \varnid & \id \\
  \id & \nid \\
  \end{pmatrix*} u = 0 \\
  \setlength\arraycolsep{0.9em}
  \begin{pmatrix*}[r]
  \varid & \id \\
  \id & \id
  \end{pmatrix*} v = 0 \\
  \setlength\arraycolsep{1.1em}
  \begin{pmatrix*}[r]
  \id & \id \\
  \id & \id
  \end{pmatrix*} v = 0
\end{align}

\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.