我想重新使用论文中使用的符号,但在 LaTeX 中格式化它时遇到了麻烦。我试图将一个小的(2x2 或 2x1 矩阵)放在箭头的顶部或右侧。我想要类似这样的内容(但矩阵用圆括号代替方括号):
我已尝试排版底行,这是我的尝试和输出:
\begin{displaymath}
\xymatrix{ G_{1} \oplus F_{2} \ar[r]^{\begin{psmallmatrix}- $\psi_{1}$ & 0 \\ g & \phi_2 \end{psmallmatrix}}
& F_{1} \oplus G_{2} \ar[r]^{\begin{psmallmatrix}- $\phi_{1}$ & 0 \\f & $\psi_2$ \end{psmallmatrix}} }
& $G_{1} \oplus F_{2}$ }
\end{displaymath}
我正在使用 xy 和 mathtools 包。
答案1
需要增加行距和列距。第一种实现对我更有吸引力,第二种实现与原图类似。
该语句@R+1pc
将行距增加1pc = 12pt;同样@C+1pc
。
\documentclass{article}
\usepackage{amsmath}
\usepackage[all,cmtip]{xy}
\newcommand{\spmat}[1]{%
\left(\begin{smallmatrix}#1\end{smallmatrix}\right)%
}
\begin{document}
\begin{equation*}
\xymatrix@C+2pc{
G_{1} \oplus F_{2} \ar[r]^{\spmat{-\psi_{1} & 0 \\ g & \phi_2}}
&
F_{1} \oplus G_{2} \ar[r]^{\spmat{-\phi_{1} & 0 \\f & \psi_2}}
&
G_{1} \oplus F_{2}
}
\end{equation*}
\begin{equation*}
\xymatrix@R+1pc@C+2pc{
F_2 \ar[r]^{\phi_2} \ar[d]^{\spmat{0 \\ 1_{F_2}}}
&
G_2 \ar[r]^{\psi_2} \ar[d]^{\spmat{0 \\ 1_{G_2}}}
&
F_2 \ar[d]^{\spmat{0 \\ 1_{F_2}}}
\\
G_1\oplus F_1 \ar[r]^{\spmat{-\psi_1 & 0 \\ g & \psi_2}}
&
F_1\oplus G_2 \ar[r]^{\spmat{-\phi_1 & 0 \\ f & \psi_2}}
&
G_1\oplus F_2
}
\end{equation*}
\begin{equation*}
\xymatrix@C+3pc{
F_2 \ar[r]^{\phi_2} \ar[d]^{\spmat{0 \\ 1_{F_2}}}
&
G_2 \ar[r]^{\psi_2} \ar[d]^{\spmat{0 \\ 1_{G_2}}}
&
F_2 \ar[d]^{\spmat{0 \\ 1_{F_2}}}
\\
G_1\oplus F_1 \ar[r]^{\spmat{-\psi_1 & 0 \\ g & \psi_2}}
&
F_1\oplus G_2 \ar[r]^{\spmat{-\phi_1 & 0 \\ f & \psi_2}}
&
G_1\oplus F_2
}
\end{equation*}
\end{document}
在嵌套数组时需要tikz-cd
小心tikzcd
。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begingroup\lccode`~=`& \lowercase{\endgroup
\newcommand{\spmat}[1]{%
\left(
\let~=&
\begin{smallmatrix}#1\end{smallmatrix}
\right)
}}
\begin{document}
\begin{equation*}
\begin{tikzcd}
G_{1} \oplus F_{2} \arrow[r,"\spmat{-\psi_{1} & 0 \\ g & \phi_2}"]
&
F_{1} \oplus G_{2} \arrow[r,"\spmat{-\phi_{1} & 0 \\f & \psi_2}"]
&
G_{1} \oplus F_{2}
\end{tikzcd}
\end{equation*}
\begin{equation*}
\begin{tikzcd}[column sep=huge,row sep=large]
F_2 \arrow[r,"\phi_2"] \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
&
G_2 \arrow[r,"\psi_2"] \arrow[d,"\spmat{0 \\ 1_{G_2}}"]
&
F_2 \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
\\
G_1\oplus F_1 \arrow[r,"\spmat{-\psi_1 & 0 \\ g & \psi_2}"]
&
F_1\oplus G_2 \arrow[r,"\spmat{-\phi_1 & 0 \\ f & \psi_2}"]
&
G_1\oplus F_2
\end{tikzcd}
\end{equation*}
\begin{equation*}
\begin{tikzcd}[column sep=4pc]
F_2 \arrow[r,"\phi_2"] \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
&
G_2 \arrow[r,"\psi_2"] \arrow[d,"\spmat{0 \\ 1_{G_2}}"]
&
F_2 \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
\\
G_1\oplus F_1 \arrow[r,"\spmat{-\psi_1 & 0 \\ g & \psi_2}"]
&
F_1\oplus G_2 \arrow[r,"\spmat{-\phi_1 & 0 \\ f & \psi_2}"]
&
G_1\oplus F_2
\end{tikzcd}
\end{equation*}
\end{document}
可以避免上述尴尬(但安全)的技巧,仍然\spmat
像 Xy-pic 案例中那样定义。缺点是需要tikzcd
以略有不同的方式输入(仅在需要嵌套数组时):
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\newcommand{\spmat}[1]{%
\left(
\begin{smallmatrix}#1\end{smallmatrix}
\right)
}
\begin{document}
\begin{equation*}
\begin{tikzcd}[ampersand replacement=\&,column sep=huge]
G_{1} \oplus F_{2} \arrow[r,"\spmat{-\psi_{1} & 0 \\ g & \phi_2}"]
\&
F_{1} \oplus G_{2} \arrow[r,"\spmat{-\phi_{1} & 0 \\f & \psi_2}"]
\&
G_{1} \oplus F_{2}
\end{tikzcd}
\end{equation*}
\begin{equation*}
\begin{tikzcd}[ampersand replacement=\&,column sep=huge,row sep=large]
F_2 \arrow[r,"\phi_2"] \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
\&
G_2 \arrow[r,"\psi_2"] \arrow[d,"\spmat{0 \\ 1_{G_2}}"]
\&
F_2 \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
\\
G_1\oplus F_1 \arrow[r,"\spmat{-\psi_1 & 0 \\ g & \psi_2}"]
\&
F_1\oplus G_2 \arrow[r,"\spmat{-\phi_1 & 0 \\ f & \psi_2}"]
\&
G_1\oplus F_2
\end{tikzcd}
\end{equation*}
\begin{equation*}
\begin{tikzcd}[ampersand replacement=\&,column sep=4pc]
F_2 \arrow[r,"\phi_2"] \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
\&
G_2 \arrow[r,"\psi_2"] \arrow[d,"\spmat{0 \\ 1_{G_2}}"]
\&
F_2 \arrow[d,"\spmat{0 \\ 1_{F_2}}"]
\\
G_1\oplus F_1 \arrow[r,"\spmat{-\psi_1 & 0 \\ g & \psi_2}"]
\&
F_1\oplus G_2 \arrow[r,"\spmat{-\phi_1 & 0 \\ f & \psi_2}"]
\&
G_1\oplus F_2
\end{tikzcd}
\end{equation*}
\end{document}
答案2
一个具有 的解tikz-cd
和一个具有 的解pstricks
:
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\newcommand{\mymatrix}[1]{\begin{psmallmatrix} #1 \end{psmallmatrix}}
\usepackage{pst-node}
\usepackage{auto-pst-pdf} %% to compile pstricks code with pdflatex
\begin{document}
\[ \begin{tikzcd}[arrows=-stealth, ampersand replacement=\&, column sep=4em, row sep=3em]%[column sep=-0.5em, row sep=0.8em]
F_2 \dar{\mymatrix{0\\\mkern-5mu\mathbf{1}_{F_2\mkern-4mu}}}\rar{\phi_2} \& G_2 \dar{\mymatrix{0\\\mkern-5mu\mathbf{1}_{G_2\mkern-4mu}}}\rar{\psi_2} \& F_2\dar{\mymatrix{0\\\mkern-5mu\mathbf{1}_{F_2\mkern-4mu}}}\\
G_1\oplus F_2\rar{\mymatrix{\mkern-5mu-\psi_1\! & 0\\g &\phi_2\mkern-4mu}} \& F_1\oplus G_2 \rar{\mymatrix{\mkern-5mu-\phi_1\! & 0\\ f &\psi_2\mkern-4mu}} \& G_1\oplus F_2
\end{tikzcd} \]
\bigskip
\[ \begin{psmatrix}[rowsep=1.25cm, colsep=1.6cm]
%% Nodes
F_2 & G_2 & F_2 \\
G_1\oplus F_2 & F_1\oplus G_2 & G_1\oplus F_2
%% Arrows and labels%
\everypsbox{\scriptstyle}
\psset{linewidth=0.6pt, arrows=->, arrowinset=0.15, nodesep=2pt, labelsep=3pt}
%% Horizontal arrows
\ncline{1,1}{1,2}\naput{\phi_2}
\ncline{1,2}{1,3}\naput{\psi_2}
\ncline{2,1}{2,2}\naput{\mymatrix{\mkern-5mu-\psi_1\! & 0\\g &\phi_2\mkern-4mu}}
\ncline{2,2}{2,3}\naput{\mymatrix{\mkern-5mu-\phi_1\! & 0\\ f &\psi_2\mkern-4mu}}
%% Vertical arrows
\psset{npos=0.45}
\ncline{1,1}{2,1}\naput{\mymatrix{0\\\mkern-5mu\mathbf{1}_{F_2\mkern-4mu}}}
\ncline{1,2}{2,2}\naput{\mymatrix{0\\\mkern-5mu\mathbf{1}_{G_2\mkern-4mu}}}
\ncline{1,3}{2,3}\naput{\mymatrix{0\\\mkern-5mu\mathbf{1}_{F_2\mkern-4mu}}}
\end{psmatrix} \]
\end{document}
答案3
这是一个利用包的机制amscd
以及包bsmallmatrix
提供的环境的解决方案mathtools
。
\documentclass{article}
\usepackage{mathtools,amscd}
\begin{document}
\[\begin{CD}
F_2 @>\phi_2>> G_2 @>\phi_2>> F_2 \\
@VV{\begin{psmallmatrix}0\\1^{}_{F_2}\end{psmallmatrix}}V
@VV{\begin{psmallmatrix}0\\1^{}_{G_2}\end{psmallmatrix}}V
@VV{\begin{psmallmatrix}0\\1^{}_{F_2}\end{psmallmatrix}}V \\
G_1\oplus F_2
@>{\smash[t]{\,\begin{psmallmatrix}
-\psi_1 & 0 \\ g & \phi_2
\end{psmallmatrix}}}>>
F_1\oplus G_2
@>{\smash[t]{\,\,\begin{psmallmatrix}
-\phi_1 & 0 \\ f & \psi_2
\end{psmallmatrix}}}>>
G_1\oplus F_2
\end{CD}\]
\end{document}
答案4
使用 tikz 的答案:
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (A) {$F_2$};
\node[right=3cm of A] (B) {$G_2$};
\node[right=3cm of B] (C) {$F_2$};
\node[below=2cm of A] (D) {$G_1\oplus F_2$};
\node[below=2cm of B] (E) {$F_1\oplus G_2$};
\node[below=2cm of C] (F) {$G_1 \oplus F_2$};
\draw[->] (A)--(B) node[midway, above] {$\phi_2$};
\draw[->] (B)--(C) node[midway, above] {$\psi_2$};
\draw[->] (D)--(E) node[midway, above,font=\small] {$\begin{pmatrix}-\psi_1 & 0\\ g& \phi_2\end{pmatrix}$};
\draw[->] (E)--(F) node[midway, above,font=\small] {$\begin{pmatrix}-\phi_1 & 0\\f& \psi_2\end{pmatrix}$};
\draw[->] (A)--(D) node[midway, right,font=\small] {$\begin{pmatrix}0\\1_{F_2}\end{pmatrix}$};
\draw[->] (B)--(E) node[midway, right,font=\small] {$\begin{pmatrix}0\\1_{G_2}\end{pmatrix}$};
\draw[->] (C)--(F) node[midway, right,font=\small] {$\begin{pmatrix}0\\1_{F_2}\end{pmatrix}$};
\end{tikzpicture}
\end{document}
我建议使用 tikz,因为它具有非常先进的用户控制功能,并且在您学习基础知识之后可以在任何地方使用它。
输出: