1

I found out that the matrices are autosized according to the entries in them.

However, this does not look very neat (well, to me). I want the matrices to be of uniform size, like perhaps matrix d:

\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsfonts}
\usepackage[left=3.50cm, right=3.0cm, top=3.0cm, bottom=3.0cm]{geometry}
\usepackage{graphicx}
\usepackage{stmaryrd}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\begin{document}
\[ d = \begin{bmatrix}
-1 & 0 & 0 \\
0 & -1 & 0 \\
0 & 0 & 1
\end{bmatrix}
\quad
x = \begin{bmatrix}
1 & 1 & 0 \\
0 &  1 & 0 \\
0 & 0 & 1
\end{bmatrix} \quad = \begin{bmatrix*}
1 & 0 & 1 \\
0 &  1 & 0 \\
0 & 0 & 1
\end{bmatrix} \]
\end{document}
  • All three matrices look they have the exact same (vertical) size. What exactly are you trying to fix? – Mico Aug 28 '17 at 8:58
  • @Mico, the vertical size is fine. I want to change the horizontal size to be that of matrix d. I don't know if it will look better or worse. – R Maharaj Aug 28 '17 at 9:04
  • your example doesn't compile. in needs mathtools, not just amsmath, and in the final matrix, the begin is starred and the end isn't. the only way i can think to modify this is to add phantoms (in rather a lot of places), and it won't look any better -- in my opinion it will look a lot worse. – barbara beeton Aug 28 '17 at 13:17
  • Try building your matrices from \left[ and \right] with array or tabular environments in between to format the data, and give the array columns a fixed-width format like p{...}. – alephzero Aug 28 '17 at 19:15
3

As alephzero suggested in his/her comment you could use an array with fixed-width columns.

To choose the appropriate column width you could use \settowidth{<your width>}{$<your longest element>$}.

\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsfonts}
\usepackage[left=3.50cm, right=3.0cm, top=3.0cm, bottom=3.0cm]{geometry}
\usepackage{graphicx}
\usepackage{stmaryrd}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{array}
\newlength{\mywid}
\newcolumntype{P}{>{\centering\arraybackslash$}p{\mywid}<{$}}
\begin{document}
    \noindent Your example as a benchmark:
    \[ d = \begin{bmatrix}
    -1 & 0 & 0 \\
    0 & -1 & 0 \\
    0 & 0 & 1
    \end{bmatrix}
    \quad
    x = \begin{bmatrix}
    1 & 1 & 0 \\
    0 &  1 & 0 \\
    0 & 0 & 1
    \end{bmatrix} \quad  = \begin{bmatrix}
    1 & 0 & 1 \\
    0 &  1 & 0 \\
    0 & 0 & 1
    \end{bmatrix} \]
    With \verb|\settowidth{\mywid}{$<put here your longest element>$}| you can set a width to use in an \verb|array| environment:
    \settowidth{\mywid}{$-1$}
    \[ 
    d = \left[\begin{array}{@{}*3P@{}}
    -1 & 0 & 0 \\
    0 & -1 & 0 \\
    0 & 0 & 1
    \end{array}\right]
    \quad
    x = \left[\begin{array}{@{}*3P@{}}
    1 & 1 & 0 \\
    0 & 1 & 0 \\
    0 & 0 & 1
    \end{array}\right] 
    \quad  
    = \left[\begin{array}{@{}*3P@{}}
    1 & 0 & 1 \\
    0 & 1 & 0 \\
    0 & 0 & 1
    \end{array}\right]
    \]
\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.