改进 tikz-cd 中矩阵作为箭头标签的外观

改进 tikz-cd 中矩阵作为箭头标签的外观
 \documentclass[a4paper,12pt,reqno]{article}

\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{titlesec}
\usepackage[top=26mm,bottom=26mm,left=26mm,right=26mm]{geometry}
\usepackage{harvard}
\usepackage[titles]{tocloft}
\usepackage{lastpage}
\usepackage[all]{xy}
\usepackage{tikz-cd}
\usepackage{mathtools,amscd}
\usepackage{tikz}
    \usetikzlibrary{calc}
    \usetikzlibrary{babel}
\usepackage{amsfonts}
\begin{document}  
 \begin{tikzcd}
k \arrow[rrd, "\begin{bmatrix}1\\0\end{bmatrix}"] \arrow[dddd, "\begin{bmatrix}a\end{bmatrix}"', bend right]       &  &                                                            &  &                                                                                                    \\
                                                                                                                   &  & k^2 \arrow[dddd, "\begin{bmatrix} c ~~ d   \end{bmatrix}"] &  & k \arrow[ll, "\begin{bmatrix}1\\1 \end{bmatrix}"'] \arrow[dddd, "\begin{bmatrix} e \end{bmatrix}"] \\
k \arrow[rru, "\begin{bmatrix}0 \\ 1 \end{bmatrix}"'] \arrow[dddd, "\begin{bmatrix} b \end{bmatrix}"', bend right] &  &                                                            &  &                                                                                                    \\
                                                                                                                   &  &                                                            &  &                                                                                                    \\
k \arrow[rrd, "1"]                                                                                                 &  &                                                            &  &                                                                                                    \\
                                                                                                                   &  & k                                                          &  & k \arrow[ll, "1"]                                                                                  \\
k \arrow[rru, "1"]                                                                                                 &  &                                                            &  &
\end{tikzcd}
\end{document}

答案1

我建议smallmatrix(需要一个小技巧来避免&):

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz-cd}

\newcommand{\sbm}[1]{{\let\amp=&\left[\begin{smallmatrix}#1\end{smallmatrix}\right]}}

\begin{document}

\begin{tikzcd}
k \arrow[rrd, "\sbm{1\\0}"] \arrow[dddd, "\sbm{a}"', bend right] &&&&\\
 && k^2 \arrow[dddd, "\sbm{ c \amp d }"] && k \arrow[ll, "\sbm{1\\1 }"'] \arrow[dddd, "\sbm{ e }"] \\
k \arrow[rru, "\sbm{0 \\ 1 }"'] \arrow[dddd, "\sbm{ b }"', bend right] &&&&\\
 &&&&\\
k \arrow[rrd, "1"] &&&&\\
 && k&& k \arrow[ll, "1"]\\
k \arrow[rru, "1"] &&&&
\end{tikzcd}

\end{document}

在此处输入图片描述

答案2

\documentclass[tikz]{standalone}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,...,4} {
    \node (k\i) at (-2,{-2*\i+3}) {$k$};
}
\node (k21) at (0,0) {$k^2$};
\node (k22) at (2,0) {$k$};
\node (k23) at (0,-4) {$k$};
\node (k24) at (2,-4) {$k$};
\draw[->] (k1) to[bend right] node[midway,left] {$\begin{bmatrix}a\end{bmatrix}$} (k3);
\draw[->] (k2) to[bend right] node[midway,left] {$\begin{bmatrix}b\end{bmatrix}$} (k4);
\draw[->] (k1)--(k21) node[midway,above right] {%
$\begin{bmatrix}
1\\0
\end{bmatrix}$
};
\draw[->] (k2)--(k21) node[midway,below right] {%
$\begin{bmatrix}
0\\1
\end{bmatrix}$
};
\draw[->] (k22)--(k21) node[midway,above] {%
$\begin{bmatrix}
1\\1
\end{bmatrix}$
};
\draw[->] (k22)--(k24) node[midway,right] {$\begin{bmatrix}e\end{bmatrix}$};
\draw[->] (k21)--(k23) node[midway,right] {%
$\begin{bmatrix}
c&d
\end{bmatrix}$};
\draw[->] (k3)--(k23) node[midway,above right] {1};
\draw[->] (k4)--(k23) node[midway,above left] {1};
\draw[->] (k24)--(k23) node[midway,below] {1};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容