5

I am using to path in order to have a better control of an arrow in a tikzcd diagram. However, I am having trouble to placement the label.

With this code

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[labels=description, column sep=3cm]
  A\arrow["a+b",sloped,rounded corners,
  to path={
    -| ([yshift=-1.5cm,xshift=-.7cm]\tikztostart.west)
    -| ([xshift=.7cm]\tikztotarget.east)\tikztonodes
    -- (\tikztotarget)} ]{r}
  & B \\ C &  D
\end{tikzcd}
\end{document}

I get this enter image description here

Moving the \tikztonode instruction to the first segment:

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[labels=description, column sep=3cm]
  A\arrow["a+b",sloped,rounded corners,
  to path={
    -| ([yshift=-1.5cm,xshift=-.7cm]\tikztostart.west)\tikztonodes
    -| ([xshift=.7cm]\tikztotarget.east)
    -- (\tikztotarget)} ]{r}
  & B \\ C &  D
\end{tikzcd}
\end{document}

I get this

enter image description here

Finally, in the last segment:

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[labels=description, column sep=3cm]
  A\arrow["a+b",sloped,rounded corners,
  to path={
    -| ([yshift=-1.5cm,xshift=-.7cm]\tikztostart.west)
    -| ([xshift=.7cm]\tikztotarget.east)
    -- (\tikztotarget)\tikztonodes} ]{r}
  & B \\ C &  D
\end{tikzcd}
\end{document}

I get this

enter image description here

How do I make it appear in the long horizontal segment at the bottom?

2
  • 1
    I just added a second way using the pos=0.25 option.
    – AndréC
    Jul 18, 2020 at 5:20
  • Awesome, thanks! In any case, I think that what I wanted was your construction. Mine was just a lack of understanding of the meaning of these -- and -|. Jul 20, 2020 at 16:33

1 Answer 1

5

New answer: without changing the construction of the path.

By default, nodes have the option pos initialized implicitly. It is enough here to initialize to [pos=0.25].

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[labels=description, column sep=3cm]
  A\arrow["a+b",rounded corners,
  to path={[pos=0.25]
    -| ([yshift=-1.5cm,xshift=-.7cm]\tikztostart.west)
    -| ([xshift=.7cm]\tikztotarget.east)\tikztonodes
    -- (\tikztotarget)} ]{r}
  & B \\ C &  D
\end{tikzcd}
\end{document}

Old answer: by modifying the construction of the path.

screenshot

\documentclass[border=5mm]{standalone}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[labels=description, column sep=3cm]
  A\arrow["a+b",rounded corners,
  to path={
    -| ([yshift=-1.5cm,xshift=-.7cm]\tikztostart.west)
    -- ([yshift=-1.5cm,xshift=.7cm]\tikztotarget.east)\tikztonodes
    |- (\tikztotarget)} ]{r}
  & B \\ C &  D
\end{tikzcd}
\end{document}

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.