3

I'm trying to draw a commutative diagram for kernel trick. I'm trying the following code:

\[ 
\begin{tikzcd}
    &X \arrow{r}{\Phi} & H& \\%
    X \times X \arrow[swap]{dr}{\pi_X} \arrow[swap]{ur}{\pi_X} \arrow{r}{k} &
    \mathbb{R} &&
    \mathcal{H} \times \mathcal{H} \arrow[swap]{ul}{\pi_\mathcal{H}} 
    \arrow[swap]{dl}{\pi_\mathcal{H}} \arrow{l}{\langle \cdot, \cdot \rangle_\mathcal{H}}\\%
    &X \arrow{r}{\Phi} & H&
\end{tikzcd}
\]

This code produces that diagram:

enter image description here

With 2 errors:

No shape named `tikz@f@5-2-3' is known. I think the culprit is a tikzcd arrow in cell 2-4.
No shape named `tikz@f@5-2-3' is known. I think the culprit is a tikzcd arrow in cell 2-4.

Actually, the diagram is almost nice except that k arrow is too short and \mathbb{R} is not centered. I guess the errors are all about this, but I'm quite new to tikz, so don't fully understand this errors. Can someone shred some light on the errors and ways to improve the diagram? Thanks.

2

You should use one more column, but you can also shorten the arrows that go over this middle columns.

I used the “modern” syntax for arrows, that I find much handier.

\documentclass{article}
\usepackage{amsmath,amssymb,tikz-cd}

\begin{document}

\[
\begin{tikzcd}
&X \arrow[rr,"\Phi"] &[-1.5em] &[-1.5em] H \\
X \times X \arrow[dr,"\pi_X"'] \arrow[ur,"\pi_X"] \arrow[rr,"k"] &&
\mathbb{R} &&
\mathcal{H} \times \mathcal{H} \arrow[ul,"\pi_\mathcal{H}"']
\arrow[dl,"\pi_\mathcal{H}"] \arrow[ll,"{\langle \cdot, \cdot \rangle_\mathcal{H}}"'] \\
&X \arrow[rr,"\Phi"] && H
\end{tikzcd}
\]

\end{document}

enter image description here

Note: I left the two plain H's, but I believe they should be \mathcal{H} as well.

1
  • Thank you for provided answer and code! Yeah, I've made a typo with H, there's of course \mathcal{H}! Jun 17 '21 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.