# How to modify a tikz-cd diagram by changing the placement and length of arrows

Consider the following code for a commutative diagram, followed by the output.

\documentclass{amsart}
\usepackage{tikz-cd}
\begin{document}
$\begin{tikzcd} A \arrow[r, leftrightarrow, "\alpha"] \arrow[d, "\int^a_b", swap] & C\quad(\subseteq S) \arrow[d, "\int^c_d"]\\ B \arrow[r, leftrightarrow, "\beta", swap] & D\quad(\subseteq T) \end{tikzcd}$
\end{document} I'd appreciate help modifying the output in the following ways.

1. The right downward arrow should be moved left so it seems to connect C to D.
2. The downward arrows should be longer.
3. The integral symbols should be longer.
• Why don't you simply use TikZ instead of tikz-cd? – JouleV Nov 16 '18 at 11:05
• @DũngVũ: I guess I could. The only reason I use tikz-cd is because the package manual contains examples that I can very easily repurpose for my needs. If I can get the same results with tikz, it would be an acceptable solution. – Evan Aad Nov 16 '18 at 11:07

## 3 Answers

You can

1. put C and (\subseteq S) in separate cells,
2. change the distances between columns and rows,
3. add \displaystyle to the integrals.

to get

\documentclass{amsart}
\usepackage{tikz-cd}
\begin{document}
$\begin{tikzcd}[column sep={8mm,between origins},row sep=1.2cm] A \arrow[rr, leftrightarrow, "\alpha"] \arrow[d, "\displaystyle\int^a_b", swap] && C \arrow[d, "\displaystyle\int^c_d"] &(\subseteq S) \\ B \arrow[rr, leftrightarrow, "\beta", swap] && D &(\subseteq T) \end{tikzcd}$
\end{document} I am not so skillful in TikZ, but hope that the following solves your first two questions

\documentclass{amsart}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node {$A$};
\draw (1.5,0) node {$C$};
\draw (0,-1.5) node {$B$};
\draw (1.5,-1.5) node {$D$};
\draw (2.5,0) node {$(\subseteq S)$};
\draw (2.5,-1.5) node {$(\subseteq T)$};
\draw[<->] (0.2,0) -- (1.3,0);
\draw[<->] (0.2,-1.5) -- (1.3,-1.5);
\draw[->] (0,-0.2) -- (0,-1.3);
\draw[->] (1.5,-0.2) -- (1.5,-1.3);
\begin{scriptsize}
\draw (0.75,0) node[above] {$\alpha$};
\draw (0.75,-1.5) node[below] {$\beta$};
\draw (0,-0.75) node[left] {$\int_b^a$};
\draw (1.5,-0.75) node[right] {$\int_d^c$};
\end{scriptsize}
\end{tikzpicture}
\end{document} For question 3: From my point of view, the integral symbol will look a bit worse if you lengthen the symbol because it doesn't suit the a, b, etc. However, if you really want to lengthen the symbol, I suggest enlarging the whole symbol:

\documentclass{amsart}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node {$A$};
\draw (1.5,0) node {$C$};
\draw (0,-1.5) node {$B$};
\draw (1.5,-1.5) node {$D$};
\draw (2.5,0) node {$(\subseteq S)$};
\draw (2.5,-1.5) node {$(\subseteq T)$};
\draw[<->] (0.2,0) -- (1.3,0);
\draw[<->] (0.2,-1.5) -- (1.3,-1.5);
\draw[->] (0,-0.2) -- (0,-1.3);
\draw[->] (1.5,-0.2) -- (1.5,-1.3);
\begin{scriptsize}
\draw (0.75,0) node[above] {$\alpha$};
\draw (0.75,-1.5) node[below] {$\beta$};
\end{scriptsize}
%\begin{small}
\draw (0,-0.75) node[left] {$\int_b^a$};
\draw (1.5,-0.75) node[right] {$\int_d^c$};
%\end{small}
\end{tikzpicture}
\end{document} 1. Reposition the arrow using the shift right option. (See tikz-cd manual.)
2. Extend the downward pointing arrows using the row sep option. (See tikz-cd manual.)
3. Stretch the integral symbols using the scalerel package, as discussed here.

Additionally,

1. The distance between an arrow and its label can be adjusted using the outer sep option, as discussed here.
2. The arrow tips can be changed using, e.g., arrow style=tikz, >=Latex. (See tikz-cd manual.)

The revised code is as follows.

\documentclass{amsart}
\usepackage{tikz-cd}
\usepackage{scalerel}
\def\stretchint#1{\vcenter{\hbox{\stretchto{\displaystyle\int}{#1}}}}
\begin{document}
$\begin{tikzcd}[row sep = huge, column sep = large, outer sep = 1mm, arrow style=tikz, >=Latex] A \arrow[r, leftrightarrow, "\alpha"] \arrow[d, "\stretchint{3ex}^a_{\hspace{-1.5mm}b}", swap] & C\quad(\subseteq S) \arrow[d, "\stretchint{3ex}^c_{\hspace{-1.5mm}d}", shift right = .6cm]\\ B \arrow[r, leftrightarrow, "\beta", swap] & D\quad(\subseteq T) \end{tikzcd}$
\end{document} 