3

This is a continuation of my previous question. I would like to draw a rectangular-like arrow with rounded corners in tikzcd and would like to put a text on this arrow. Here is my attempt:

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz-cd}
\usepackage[english]{babel}
\usepackage{relsize}
\tikzset{nodes={inner sep=2pt}}
\usepackage{blindtext}

\begin{document}
\[\begin{tikzcd}[sep=34pt]
    B \ar{r}[swap]{g}
    \ar[to path={ -- ([yshift=-4ex]\tikztostart.south) -| (\tikztotarget)},
        rounded corners=12pt]{rr}
    & B' \ar{r}[swap]{g'}
    \ar[phantom]{d}[pos=0.45]{\mathsmaller{g' \circ g}} & B'' \\
    & \phantom{.} &
 \end{tikzcd}\]
\blindtext

\end{document}

The problem is that the phantom node produces extra white space in the tikzpicture, so that the text after it does not come directly after it.

There is a "dirty" solution using \vspace{-10mm} after the tikzpicture, but this is not very precise and not elegant.

2
  • 1
    if I put this in an MWE, it does look slightly different to your screen-shot. Please complete your example. Also add this text which "comes directly after it".
    – LaRiFaRi
    Feb 23, 2016 at 9:11
  • \ar[to path={ -- ([yshift=-4ex]\tikztostart.south) -| node[pos=0.25,above]{$\mathsmaller{g' \circ g}$} (\tikztotarget)}, rounded corners=12pt]{rr} & B' \ar{r}[swap]{g'}?
    – user277428
    Jul 30, 2022 at 18:59

1 Answer 1

1

You can add a node at the end of drawing that picture. But this still needs manual positioning of the label. At least you do not generate extra space here:

% arara: pdflatex

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

\begin{document}
\begin{tikzcd}[sep=large, execute at end picture={\node[below = 1mm of tikz@f@1-1-2] {$\scriptstyle  g' \circ g$};}]
    B \ar{r}[swap]{g\vphantom{'}}
    \ar[to path={ -- ([yshift=-4ex]\tikztostart.south) -| (\tikztotarget)},
    rounded corners=12pt]{rr}
    & B' \ar{r}[swap]{g'} & B'' \\
\end{tikzcd}
\end{document}

enter image description here

3
  • Thank you! For some reason, in my main file, there is an error that no shape named tikz@f@1-1-2 is known. When I copy the whole diagram into a minimal example, with the same preamble, it works. That's very strange ... Anyway, you have answered my question. Feb 23, 2016 at 13:31
  • @MartinBrandenburg Try to reduce your code until you find the culprit part. Line by line.
    – LaRiFaRi
    Feb 23, 2016 at 13:36
  • What to do if there are even number of nodes? I mean, the label should be below and between 2nd and 3rd nodes.
    – Sigur
    Jun 25, 2016 at 19:29

You must log in to answer this question.

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