How can I program the above diagram? `
$$ \begin{tikzcd} k\oplus k^2 \arrow[r] & k\oplus k^2 & 0\oplus k \arrow[l] \end{tikzcd} $$
`
How can I program the above diagram? `
$$ \begin{tikzcd} k\oplus k^2 \arrow[r] & k\oplus k^2 & 0\oplus k \arrow[l] \end{tikzcd} $$
`
Here are two realizations; to be honest, I'd prefer the second one. For the first, I define a variant of smallmatrix
with increased line spacing.
Note that ampersand replacement
is needed as you want to use &
for the matrices.
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\usepackage{etoolbox}
\makeatletter
\let\xsmallmatrix\smallmatrix
\let\endxsmallmatrix\endsmallmatrix
\patchcmd{\xsmallmatrix}{6\ex@}{12\ex@}{}{}
\newenvironment{bxsmallmatrix}
{\left[\xsmallmatrix}
{\endxsmallmatrix\right]}
\makeatother
\begin{document}
\[
\begin{tikzcd}[ampersand replacement=\&,column sep=huge]
k\oplus k^2
\arrow[r,"{\begin{bxsmallmatrix}1&0&0\\0&1&1\\0&0&1\end{bxsmallmatrix}}"]
\&
k\oplus k^2
\&
0\oplus k \arrow[l,"{\begin{bxsmallmatrix}0&0\\0&1\\0&1\end{bxsmallmatrix}}"']
\end{tikzcd}
\]
\[
\begin{tikzcd}[ampersand replacement=\&,column sep=huge]
k\oplus k^2
\arrow[r,"{\begin{bsmallmatrix}1&0&0\\0&1&1\\0&0&1\end{bsmallmatrix}}"]
\&
k\oplus k^2
\&
0\oplus k \arrow[l,"{\begin{bsmallmatrix}0&0\\0&1\\0&1\end{bsmallmatrix}}"']
\end{tikzcd}
\]
\end{document}
A simple code with tikz-cd
and the bsmallmatrix
environment from mathtools
\documentclass[11pt]{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\begin{document}
\[
\begin{tikzcd}[row sep=1.2cm, column sep=2cm, arrows=-stealth, ampersand replacement=\&]
k\oplus k^2\rar{\begin{bsmallmatrix}1 & 0 & 0\\0 & 1 & 1\\0 & 0 & 1\end{bsmallmatrix}} \& k\oplus k^2\& \lar[swap]{\begin{bsmallmatrix}0 & 0\\0 & 1\\ 0 & 1\end{bsmallmatrix}} 0\oplus k
\end{tikzcd}
\]
\end{document}
Edit :
To have control on the horizontal spacing in the matrices, you can use the bmatrix
environment, and use the classical tools \arraystretch
and \arraycolsep
(defaults 1
and 5pt
respectively). For instance:
\[ \renewcommand{\arraystretch}{0.7}\setlength{\arraycolsep}{3pt}
\begin{tikzcd}[row sep=1.2cm, column sep=2cm, arrows=-stealth, ampersand replacement=\&]
k\oplus k^2\rar{\begin{bmatrix}1 & 0 & 0\\0 & 1 & 1\\0 & 0 & 1\end{bmatrix}} \& k\oplus k^2\& \lar[swap]{\begin{bmatrix}0 & 0\\0 & 1\\ 0 & 1\end{bmatrix}} 0\oplus k
\end{tikzcd}
\]
yields this diagram:
It suffices to use the basic tools of the tikz-machinery. In fact, the following code is only a very simple exercise and you can modify it further according to your notion.
\documentclass{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\node (A) {$k\oplus k^2$};
\node (B) at ($(A)+(3,0)$) {$k\oplus k^2$};
\node (C) at ($(B)+(3,0)$) {$0\oplus k$};
%
\draw[-stealth]
(A) -- (B)
node[midway,above,scale=.5]
{$\begin{bmatrix}
1& 0& 0\\
0& 1& 0\\
0& 0& 1
\end{bmatrix}$};
\draw[-stealth]
(C) -- (B)
node[midway,above,scale=.5]
{$\begin{bmatrix}
0& 0\\
0& 1\\
0& 1
\end{bmatrix}$};
\end{tikzpicture}
\end{document}
double
to the \draw
-command, i.e., \draw[-stealth,double]
. However, I'm not sure about your formulation "double arrow".
Commented
Jul 17, 2018 at 7:08