1

The tikz-cd package comes with plenty of arrow head and tail options, but there are some more adventurous applications that are harder to implement. In my particular case, I would like to replace the arrow with a long triangle, as illustrated in this mock-up:

enter image description here

There are dedicated chemistry notation packages with this kind of arrow/bond packages available, but I want the output to be consistent with the other diagrams I have in my work, so a tikz-cd-based option would be preferred. A solid triangle would also be acceptable if that is easier for whatever reason.

MWE (outputs dashed line where I would like the triangle to be):

\documentclass[11pt]{article}
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}
K \ar[dr,dashed, no head] & & \\
& A \ar[dr,two heads] & \\
& & X
\end{tikzcd}

\end{document}
3
  • Adding a minimal working example (MWE) to your question would be nice, so that helpers would not be forced to do all the job.
    – SebGlav
    Sep 5, 2021 at 10:10
  • 1
    Pretty sure an MWE is more useful for identifying problems/sources of errors in code, but okay, I've added one. Sep 5, 2021 at 13:30
  • Thank you. A MWE is also useful to copy/paste and strat adding what you need ;)
    – SebGlav
    Sep 5, 2021 at 13:50

1 Answer 1

4

So, here's a solution that involves remember picture and to draw afterwards your tikz-cd, but I think it could be enough for your purpose.

new arrow type on tikz-cd

\documentclass[11pt]{article}
\usepackage{tikz-cd}
\usetikzlibrary{calc}

\newcommand{\triar}[2]{
    \draw[orange] ($(#2)!0.2!(#1)$) -- ($ (#2)!0.8! 10:(#1) $) -- ($ (#2)!0.8! -10:(#1) $)  --cycle;
    }
    
\begin{document}

    \begin{tikzcd}[remember picture]
        |[alias=K]|K  & & \\
        & |[alias=A]|A \ar[dr,two heads] & \\
        & & X
    \end{tikzcd}
    
    \begin{tikzpicture}[overlay,remember picture]
        \triar{K}{A};
    \end{tikzpicture}

\end{document}

If you're not familiar with the calc library, when you type ($ (#2)!0.8! 10:(#1) $), it means the point between arg2 and arg1 (here between A and K), but with an additional turn by 10°. The triangle is made with this. You can change the value of the angle like you want.

Of course, the orange colour is only here to emphasize the new arrow.

EDIT

Here's a little variation, letting you pass the angle as a parameter, because on more complex diagrams, it could be interesting to customize that point.

\documentclass[11pt]{article}
\usepackage{tikz-cd}
\usetikzlibrary{calc}

\newcommand{\triar}[3]{
    \draw[orange] ($(#2)!0.1!(#1)$) -- ($ (#2)!0.9! #3:(#1) $) -- ($ (#2)!0.9! -#3:(#1) $)  --cycle;
    }
    
\begin{document}
    \begin{tikzcd}[remember picture]
        |[alias=A]|A \arrow{d} \arrow{r}[near start]{\phi}[near end]{\psi}
        & |[alias=B]|B  & |[alias=E]| E\\
        |[alias=C]|C \arrow[red]{r}[blue,below]{\eta}
        & |[alias=D]|D \arrow[purple]{r}[green,below]{\nu} & |[alias=F]| F
    \end{tikzcd}
    
    \begin{tikzpicture}[overlay,remember picture]
        \triar{E}{C}{2};
    \end{tikzpicture}

\end{document}

I also changed the percentage to .1 and .9 for start and end of the triangle, it seems better to me like this.

custom arrow shape 2

And of course, I know this commutative diagram is absurd, it's just to show the new arrow properties.

4
  • If I wanted to do this for arrows in different directions or at different lengths, do you expect it would adapt okay? Sep 5, 2021 at 14:22
  • Since the triangle is drawn using direct coordinates of the nodes, I think yes. You may try by yourself. I'll try also.
    – SebGlav
    Sep 5, 2021 at 14:36
  • Post edited accordingly. Hope this fullfills your needs.
    – SebGlav
    Sep 5, 2021 at 15:41
  • 1
    You did a great job.
    – Sebastiano
    Sep 5, 2021 at 21:57

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.