7

I'm trying to make a typical composing-function diagram and I've saw a few posts, but I cannot make it yet as I'd like. In this picture I show what I attempt to make enter image description here

But the most I got is

enter image description here

As you can see, I used empty nodes for the broken line, but not exactly worthy. I leave my code here so you can help me with its edition. I must confess I'm basic user in Latex and 100% newbie in Tikz, so any guide you use is welcome.

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[node distance=2cm, auto]
    \node(1) {$C$};
    \node(2) [right of=1] {$C_{0}$};
    \node(3) [right of=2] {$P_{0}$};
    \node(4) [right of=3] {$P$};
    \node(5) [right of=4] {$f^{*}(P)$};
    \node(11) [below of=1] {};
    \node(15) [below of=5] {};
    \draw[->](1) to node {$\tau_{c}^{-1}$}(2);
    \draw[->](2) to node {$l^{-1}$}(3);
    \draw[->](3) to node {$\tau_{-1}$}(4);
    \draw[->](4) to node {$f^{*}$}(5);
    \draw[-](1) to node {}(11);
    \draw[->](15) to node {}(5);
    \draw[-](11) to node {$f = \tau_{c}^{-1} \circ l^{-1} \circ \tau_{-1} \circ f^{*}$}(15);

\end{tikzpicture}

\end{document}

Thanks

2
  • 2
    Welcome on TeX.SE. Take a look at this post
    – JeT
    Mar 25 at 18:48
  • 1
    @JeT Thanks, I'm reading it. Been myselft such a newbie, a whole manual is more useful, but thanks.
    – Suiron
    Mar 25 at 19:02

3 Answers 3

7

You were almost at it.

First version with too much vertical space: pic

Second one with reduced vertical space: V2

You can adjust everything by paying attention to the code. The important part is --++(0,-1) here which draws a vertical line of 1cm length.

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[node distance=2cm, auto]
    \node(1) {$C$};
    \node(2) [right of=1] {$C_{0}$};
    \node(3) [right of=2] {$P_{0}$};
    \node(4) [right of=3] {$P$};
    \node(5) [right of=4] {$f^{*}(P)$};
    \node(11) [below of=1] {};
    \node(15) [below of=5] {};
    \draw[->](1) to node {$\tau_{c}^{-1}$}(2);
    \draw[->](2) to node {$l^{-1}$}(3);
    \draw[->](3) to node {$\tau_{-1}$}(4);
    \draw[->](4) to node {$f^{*}$}(5);

    % \draw[->] (1) --++ (0,-2) -| node[pos=0.25] {$f = \tau_{c}^{-1} \circ l^{-1} \circ \tau_{-1} \circ f^{*}$} (5); %(old version)

    \draw[->] (1) --++ (0,-1) -| node[pos=0.25,below] {$f = \tau_{c}^{-1} \circ l^{-1} \circ \tau_{-1} \circ f^{*}$} (5);

\end{tikzpicture}

\end{document}
3
  • That's close indeed! How can I make the vertical lines shorter? There's too much empty space at my diagram. And how to make the composition label to appear below the line?
    – Suiron
    Mar 25 at 19:00
  • I'll edit my answer as requested.
    – SebGlav
    Mar 25 at 19:01
  • 3
    Thanks you both. Once you have a comand (or optional arguments for it), making little changes on it helps a lot to see how it works.
    – Suiron
    Mar 25 at 19:09
6

Alternative possibility where are employ tikz libraries arrows.meta (for arrows), chains (for make chain of nodes), positioning (for distances between nodes) and quotes )for edge lables):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, 
                chains,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[auto,
node distance = 8mm and 12mm, 
  start chain = A going right,
every edge/.style = {draw, -Straight Barb}
                        ]
\foreach \i in {C, C_0, P_0, P, f^{*}(P)}
    \node[on chain=A] {$\i$};
\coordinate[below=of A-5]  (A-6);
\draw   (A-1) edge["$\tau_{c}^{-1}$"]   (A-2) 
        (A-2) edge["$l^{-1}$"]          (A-3) 
        (A-3) edge["$\tau_{-1}$"]       (A-4) 
        (A-4) edge["$f^{*}$"]           (A-5)
        (A-1) |- (A-6)  node[pos=0.75, below] 
                        {$f = \tau_{c}^{-1} \circ l^{-1} \circ \tau_{-1} \circ f^{*}$} 
        (A-6) edge (A-5);
    \end{tikzpicture}
\end{document}

enter image description here

4

The code is quite short with a normal displaymath environment, using \xrightarrow and pstricks(more precisely with pst-node):

\documentclass{article}
\usepackage{amsmath}
\usepackage{pst-node} 

\begin{document}

  \[ \rnode{C}{C} \xrightarrow[\rule{3em}{0pt}]{\tau_c^{-1}} C_0 \xrightarrow[\rule{3em}{0pt}]{l^{-1}}P_0 \xrightarrow[\rule{3em}{0pt}]{\tau_{-1}}P 0\xrightarrow[\rule{3em}{0pt}]{f*}\rnode{F}{f^*(P)}
  \psset{linewidth=0.5pt, angle = -90, arm=0.8cm, arrowinset=0.15, nodesepA=3pt, linejoin=1}
  \ncbar{->}{C}{F} \nbput{f^*\circ \tau_{-1}\circ l^{-1}\circ \tau_c^{-1}}
  \]%

\end{document} 

enter image description here

2
  • Yeap, I thought at \xrightarrow at first, but as I had no idea to manage the large line, I start to search info and tought it would be easier with just one enviroment than mixing them. But it's a nice approach anyway and can be useful in the future.
    – Suiron
    Mar 25 at 21:59
  • Thank you for your kind comment. The advantage of pstricks is that it can be used without any problem within math environments.
    – Bernard
    Mar 25 at 22:24

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.