![矩阵上三角对齐](https://linux22.com/image/401475/%E7%9F%A9%E9%98%B5%E4%B8%8A%E4%B8%89%E8%A7%92%E5%AF%B9%E9%BD%90.png)
我正在编写一个上三角矩阵,但由于条目太多而无法获得良好的视图。
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,mathtools}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
$$ J(\hat{\Phi})(p)=
\begin{pmatrix*}[c]
((\hat{\Phi}(p)_{ij}))_{i,j=1}^r &\hdots & & &\hdots & ((\hat{\Phi}(p)_{ij}))_{i,j=1}^r \\
& \ddots & & \vdots\\
& & \ddots & &((\partial^{\alpha}\partial^{\beta}\hat{\Phi}(p)_{ij}))_{i,j=1}^r & \vdots \\
\text{\huge0} & & & & \\
& & & & & ((\partial_d^{k-1}\hat{\Phi}(p)_{ij}))_{i,j=1}^r
\end{pmatrix*}
$$
\end{document}
答案1
如果你愿意加载tikz
,你可以这样做
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\[ J(\widehat{\Phi})(p)=
\begin{pmatrix*}[c]
\tikzmarknode{tl}{((\widehat{\Phi}(p)_{ij}))_{i,j=1}^r} &
\hspace*{9em}&
\tikzmarknode{tr}{((\widehat{\Phi}(p)_{ij}))_{i,j=1}^r} \\[4em]
\tikzmarknode{bl}{~} & &
\tikzmarknode{br}{((\partial_d^{k-1}\widehat{\Phi}(p)_{ij}))_{i,j=1}^r}
\end{pmatrix*}
\begin{tikzpicture}[overlay,remember picture,Dotted/.style={%https://tex.stackexchange.com/a/101263/194703
line width=#1, line cap=round, dash pattern=on 0pt off 4\pgflinewidth},
Dotted/.default=1.5pt,shorten/.style={shorten >=#1/2,shorten <=#1/2}]
\draw[Dotted,shorten=4ex] (tl) -- (tr);
\draw[Dotted,shorten=4ex] (tr) -- (br);
\draw[Dotted,shorten=5ex] (tl) -- (br) node[pos=0.5,inner sep=0pt,above
right]
{$((\partial^{\alpha}\partial^{\beta}\widehat{\Phi}(p)_{ij}))_{i,j=1}^r$} ;
\node[scale=3,above] at (bl.south west) {$0$};
\end{tikzpicture}
\]
\end{document}
您还可以使用nicematrix
(使用 Ti钾Z)。
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{nicematrix}
\begin{document}
\[ J(\widehat{\Phi})(p)=
\begin{pNiceMatrix}[name=mymatrix]
((\widehat{\Phi}(p)_{ij}))_{i,j=1}^r &
\Cdots \Hspace*{7em}& ((\widehat{\Phi}(p)_{ij}))_{i,j=1}^r\\[2em]
&\Ddots & \Vdots \\[2em]
~ & &
((\partial_d^{k-1}\widehat{\Phi}(p)_{ij}))_{i,j=1}^r\\
\end{pNiceMatrix}
\begin{tikzpicture}[overlay,remember picture]
\path (mymatrix-1-1) -- (mymatrix-3-3)
node[pos=0.5,above right,inner sep=0pt]
{$((\partial^{\alpha}\partial^{\beta}\widehat{\Phi}(p)_{ij}))_{i,j=1}^r$} ;
\node[scale=3,above] at (mymatrix-3-1) {$0$};
\end{tikzpicture}
\]
\end{document}
答案2
这里有两个版本,因为我不确定你是否希望中心元素在对角线上或对角线外
在哪里
- 我曾经
\mathrlap
隐藏下标和上标以防影响列宽,以便它们\ddots
出现在它们下面, - 用于
\smash
大零,因此它不会影响垂直间距, - 用于
\multicolumn{}{}{}
中心元素偏离对角线的情况,以及 - 消除了此示例中不需要的包。
代码:
\documentclass{article}
\usepackage{mathtools}
\newcommand*{\A}{((\hat{\Phi}(p)_{ij}))\mathrlap{{}_{i,j=1}^r}}%
\newcommand*{\B}{((\partial^{\alpha}\partial^{\beta}\hat{\Phi}(p)_{ij}))\mathrlap{{}_{i,j=1}^r}}%
\newcommand*{\C}{((\partial_d^{k-1}\hat{\Phi}(p)_{ij}))_{i,j=1}^r}
\newcommand*{\BigZ}{\hspace*{2.0em}\smash{\text{\Huge0}}}
\begin{document}
\[
J(\hat{\Phi})(p)=
\begin{pmatrix*}[c]
\A & & \hdots & \hdots & \A \\
& \ddots & & & \vdots \\
& & \B & & \vdots \\
\BigZ & & & \ddots & \vdots \\
& & & & \C \\
\end{pmatrix*}
\]
\end{document}
代码:对角线中央元素
\documentclass{article}
\usepackage{mathtools}
\newcommand*{\A}{((\hat{\Phi}(p)_{ij})){{}_{i,j=1}^r}}%
\newcommand*{\B}{((\partial^{\alpha}\partial^{\beta}\hat{\Phi}\mathrlap{(p)_{ij})){}_{i,j=1}^r}}%
\newcommand*{\C}{((\partial_d^{k-1}\hat{\Phi}(p)_{ij}))_{i,j=1}^r}
\newcommand*{\BigZ}{\hspace*{2.0em}\smash{\text{\Huge0}}}
\begin{document}
\[
J(\hat{\Phi})(p)=
\begin{pmatrix*}[c]
\A & \hdots & \hdots & \hdots & \hdots & \A \\
& \ddots & & & & \vdots \\
& & \ddots & \multicolumn{2}{c}{\B} & \vdots \\
\BigZ & & & \ddots & & \vdots \\
& & & & \ddots & \vdots \\
& & & & & \C \\
\end{pmatrix*}
\]
\end{document}
答案3
像这样吗?
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools,amssymb}
\begin{document}
\[
\setlength\arraycolsep{2.5pt} % default value: 5pt
J(\widehat{\Phi})(p)=
\begin{pmatrix}
\bigl((\widehat{\Phi}(p)^{}_{ij})\bigr)_{i,j=1}^r &\dots &\dots & \dots &
\bigl((\widehat{\Phi}(p)^{}_{ij})\bigr)_{i,j=1}^r \\
& \ddots & \vdots & & \vdots\\
& &\bigl((\partial^{\alpha}\partial^{\beta}\widehat{\Phi}(p)^{}_{ij})\bigr)_{i,j=1}^r & & \vdots \\
& & & \ddots & \vdots \\
\hbox{\huge0} & & & & \bigl((\partial_d^{k-1}\widehat{\Phi}(p)^{}_{ij})\bigr)_{i,j=1}^r
\end{pmatrix}
\]
\end{document}