4

I'd like to strike out the arrow between C and D in the following commutiative diagram defined using the cd Tikz library:

enter image description here

Building on this answer I came up with the following code that gives me the above result without the desired striked out arrow:

\documentclass{article}

\usepackage{tikz}
    \usetikzlibrary{cd}
    \usetikzlibrary{shapes.misc}

\begin{document}
    \begin{figure}
        \[
        \begin{tikzcd}
            A \arrow[leftrightarrow]{r} \arrow{d} & B \arrow{d} \\
            C \arrow[leftrightarrow,strike out]{r} & D
        \end{tikzcd}
        \]
    \end{figure}
\end{document}
0

2 Answers 2

4

Even easier than Enrico's solution...

\documentclass{article}

\usepackage[main=ngerman,english]{babel}
\usepackage{tikz}
\usetikzlibrary{babel,cd}

\begin{document}

\[
\begin{tikzcd}
A \arrow[r,leftrightarrow] \arrow[d] & B \arrow[d] \\
C \arrow[r,"/"{anchor=center,sloped},leftrightarrow] & D
\end{tikzcd}
\]

\end{document}

The sloped option is actually not needed in this case but comes in handy for vertical or curvy arrows.

enter image description here

5
  • Your solution does unfortunately not work on my machine when adding \usepackage[main=ngerman,english]{babel} at the end of the preamble. Jan 8, 2018 at 9:00
  • Missing \endcsname inserted. \end{tikzcd} and Package xcolor Error: Undefined color \penalty \@M \hskip \z@skip \discretionary {/}{}{/}\penalty \@M \hskip \z@skip "anchor=center,sloped'. I think the culprit is a tikzcd arrow in cell 2-1. Jan 8, 2018 at 9:02
  • @Christoph90 See updated answer. Jan 8, 2018 at 9:20
  • I'm going to accept this answer, since it does the job and is more compact. However, I feel bad for not being able to accept egregs great answer too :) Jan 8, 2018 at 10:16
  • @Christoph90 You should always accept the answer that you like most. Otherwise the whole accepted-answer-business is pointless. Jan 8, 2018 at 10:38
4

A modification of https://tex.stackexchange.com/a/51024/4427

\documentclass{article}

\usepackage{tikz-cd}
\usetikzlibrary{decorations.markings}
\tikzset{
  negate/.style={
    decoration={
      markings,
      mark= at position 0.5 with {
        \node[transform shape] (tempnode) {$/$};
      },
    },
    postaction={decorate},
  },
}

\begin{document}

\[
\begin{tikzcd}
A \arrow[r,leftrightarrow] \arrow[d] & B \arrow[d] \\
C \arrow[r,leftrightarrow,negate] & D
\end{tikzcd}
\]

\end{document}

There is no need to use a figure environment for a diagram. Also arrows are more uniformly specified in the above fashion.

enter image description here

1
  • 1
    \arrow[r,leftrightarrow,"/" anchor=center], see my answer. Jan 8, 2018 at 1:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .