答案1
您可以设置\arraycolsep
为负值:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
\begingroup
\setlength\arraycolsep{-5pt}
\begin{bmatrix}
-V_1V_2b_{21} & & & & \\
& -V_2V_3b_{32} & & & \\
& & -V_1V_3b_{13} & & \\
& & & -V_3V_4b_{34} & \\
& & & & -V_1V_4b_{41}
\end{bmatrix}
\endgroup
\]
\end{document}
\begingroup
并\endgroup
用于保持本地变化。
答案2
https://tex.stackexchange.com/a/337013/197451
\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\newcommand\shrink{\hspace{-3em}}
$$
\begin{bmatrix}
-V_1V_2b_{21}\shrink & & & & \\
& -V_2V_3b_{32}\shrink & & & \\
& & -V_1V_3b_{13}\shrink & & \\
& & & -V_3V_4b_{34} \shrink& \\
& & & & -V_1V_4b_{41}
\end{bmatrix}
\quad
$$
\end{document}
答案3
下面我使用单列数组,其中条目根据最宽条目的预定义因子进行移动,可以使用可选参数进行选择(默认值为 0.5)。
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\diagonal}{ O{0.5} m }
{% #1 = indent factor, #2 = list of entries
\gouhaha_diagonal:nn { #1 } { #2 }
}
% a box for measuring the entries, a length for storing the max
\box_new:N \l__gouhaha_diagonal_box
\dim_new:N \l__gouhaha_diagonal_dim
% a sequence for storing the entries
\seq_new:N \l__gouhaha_diagonal_seq
\cs_new_protected:Nn \gouhaha_diagonal:nn
{
% store the entries
\seq_set_from_clist:Nn \l__gouhaha_diagonal_seq { #2 }
% let's get the max width
\dim_zero:N \l__gouhaha_diagonal_dim
\seq_map_inline:Nn \l__gouhaha_diagonal_seq
{
\hbox_set:Nn \l__gouhaha_diagonal_box { $##1$ }
\dim_set:Nn \l__gouhaha_diagonal_dim
{
\dim_max:nn { \l__gouhaha_diagonal_dim } { \box_wd:N \l__gouhaha_diagonal_box }
}
}
% now set the length to the overlap (plus the \arraycolsep)
\dim_set:Nn \l__gouhaha_diagonal_dim { #1\l__gouhaha_diagonal_dim }
% make the matrix
\begin{bmatrix}
\begin{array}{@{}l@{}}
\seq_indexed_map_function:NN \l__gouhaha_diagonal_seq \__gouhaha_diagonal_entry:nn
\end{array}
\end{bmatrix}
}
\cs_new_protected:Nn \__gouhaha_diagonal_entry:nn
{
\int_compare:nF { #1 = 1 } { \\ }
\hspace{ \int_eval:n {(#1-1)}\l__gouhaha_diagonal_dim }
#2
}
\ExplSyntaxOff
\begin{document}
\[
\diagonal{-V_1V_2b_{21}, -V_2V_3b_{32}, -V_1V_3b_{13}, -V_3V_4b_{34}, -V_1V_4b_{41}}
\]
\[
\diagonal[0.25]{-V_1V_2b_{21}, -V_2V_3b_{32}, -V_1V_3b_{13}, -V_3V_4b_{34}, -V_1V_4b_{41}}
\]
\[
\diagonal[0.75]{-V_1V_2b_{21}, -V_2V_3b_{32}, -V_1V_3b_{13}, -V_3V_4b_{34}, -V_1V_4b_{41}}
\]
\end{document}
该\seq_indexed_map_function:NN
函数非常有用,因为它同时提供了循环索引和当前序列项。