Isomorphisms in commutative diagrams in TikZ

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}

enter image description here


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);

enter image description here


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);

enter image description here


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

\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}

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.

Tags:

Tikz Pgf