我发现矩阵是根据其中的条目自动调整大小的。
但是,这看起来不太整洁(对我来说)。我希望矩阵具有统一的大小,例如矩阵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}
答案1
正如 alephzero 在他/她的评论中所建议的,您可以使用具有固定宽度列的数组。
要选择合适的列宽,您可以使用\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}