# Isomorphisms in commutative diagrams in TikZ

Sorry for the basic question. I am trying to get commutative diagrams like

\usepackage{tikz}
\usetikzlibrary{matrix,arrows}
$$\begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}] \matrix (m) [matrix of math nodes, row sep=3em, column sep=2.5em, text height=1.5ex, text depth=0.25ex] {A & B \\ C& D \\ }; \path[->,font=\scriptsize] (m-1-1) edge node[auto] {\widetilde {f} } (m-1-2) (m-2-1) edge node[auto] { f } (m-2-2); \draw[double equal sign distance,shorten <=5pt,shorten >=5pt] (m-1-2) -- (m-2-2); \draw[double equal sign distance,shorten <=5pt,shorten >=5pt] (m-1-1) -- (m-2-1); \end{tikzpicture}$$


My question is: How do I replace the vertical equal sign connecting $A$ to $C$ with a vertical isomorphism sign, a vertical version of $\simeq$ or $\approx$?

I tried to modifiy your code, but it only resulted in weird shifting and not the desired result at all. As an OCD like control freak, I always position "by hand", so tell me if this works for you:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows}

\begin{document}

\begin{tikzpicture}
\node (A) at (0,0) {A};
\node (B) at (2,0) {B};
\node (C) at (0,-2) {C};
\node (D) at (2,-2) {D};
\draw (A) edge node[above] {$\widetilde {f}$} (B);
\draw (C) edge node[above] {$f$} (D);
\draw (A) edge node[above,rotate=90] {$\simeq$} (C);
\draw (B) edge node[above,rotate=90] {$\approx$} (D);
\end{tikzpicture}

\end{document}


Edit 1: With some "cheated" changes as wh1te proposed:

\draw[white] (A) edge node[rotate=90,black] {$\simeq$} (C);
\draw[white] (B) edge node[rotate=90,black] {$\approx$} (D);


Edit 2: Of cause, one would still see the lines on a non-white background, so this should be better:

\draw[transparent] (A) edge node[rotate=90,opacity=1] {$\simeq$} (C);
\draw[transparent] (B) edge node[rotate=90,opacity=1] {$\approx$} (D);


Edit 3: I could not think of any automated way right now, but you could use a \resizebox:

\draw[transparent] (A) edge node[rotate=90,opacity=1] {\resizebox{1.5cm}{0.3cm}{$\simeq$}} (C);
\draw[transparent] (B) edge node[rotate=90,opacity=1] {\resizebox{1.5cm}{0.3cm}{$\approx$}} (D);


• My understanding was that he wanted the actual line connecting the two nodes to be like that symbol, not just label the existing line. So a snake decoration could probably be used to do the job. Commented Feb 13, 2012 at 16:06
• Thank you for the response Tom. I am happy to learn of how to do this too. But I was preferring as whlt3 suggested, to be able to make the whole line connecting the two nodes as the isomorphism sign
– clh
Commented Feb 13, 2012 at 16:12
• This is almost what I had in mind, but can you make the isomorphism signs fill the space between the nodes more, like the double equals sign does in my example.
– clh
Commented Feb 13, 2012 at 16:17
• Possible instead of resizebox :  \path (C) -- node[sloped,transform shape,inner sep=0pt,xscale=6] {$\simeq$} (A) ;  Commented Feb 13, 2012 at 21:52
• Where are the arrows? It's impossible to see the "directions".
– user10274
Commented Feb 13, 2012 at 23:29

I like to use tikz-cd for commutative diagrams. Here is how I am indicating isomorphisms.

\documentclass{amsart}
\usepackage{tikz-cd}
\usepackage{rotating}
\newcommand*{\isoarrow}[1]{\arrow[#1,"\rotatebox{90}{$$\sim$$}"
]}
\begin{document}
$\begin{tikzcd} 0 \arrow{r} & A \arrow{r} \isoarrow{d} & B \arrow{r} \isoarrow{d} & C \arrow{r} \isoarrow{d} & 0 \\ 0 \arrow{r} & A' \arrow{r} & B' \arrow{r} & C' \arrow{r} & 0 \end{tikzcd}$
\end{document}

• It doesn't work for horizontal or diagonal isomorphisms. I hope someone will figure out a better way. Commented Apr 26, 2015 at 12:22

I took this from a style for Subseteq to be vertical or horizontal.

\tikzset{cong/.style={draw=none,edge node={node [sloped, allow upside down, auto=false]{$\cong$}}},
Isom/.style={draw=none,every to/.append style={edge node={node [sloped, allow upside down, auto=false]{$\cong$}}}}}


Load the code in the preamble, then in tikzcd

$\begin{tikzcd} \ker(f)\arrow[hook]{r}&B\\ A\arrow{ur}{i}\arrow[Isom]{u} \end{tikzcd}$


It seems to work well for me.

• This is great! To make the arrow appear, remove draw=none and add above instead. To flip the label so it appears on the other side, add rotate=180 to the list inside the square brackets. Commented Jun 3, 2016 at 9:43