3

enter image description here

Building on a previous question of mine about tikzpicture, how do I get the encircled arrows in the image as arrows between nodes, and what is the name of the symbol? I assume I still use draw but I have not been able to figure it out. Also a list of arrow-options for draw would be appreciated.

Currently I have the following:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{positioning, arrows.meta}
\begin{document}
\begin{tikzpicture}
\node at (0,0) (qob) {Quarter of Birth};
\node[right=1cm of qob] (sch) {Schooling};
\node[right=1cm of sch] (wage) {Wage};
\node[below=1cm of sch] (abi) {Ability $\in \:u$};

\draw[$\nsenwarrows$] (abi) to (sch);
\draw[->, red] (abi) to (sch);
\draw[->] (abi) to (wage);
\draw[->] (qob) to (sch); %here I want to have "relevance" above the arrow
\draw[->] (sch) to (wage); %here i want a "?" above the arrow
\draw[\n$\nsenwarrows$] %here I want to replace the arrow with \nsenwarrows and write "exogeneity" below

\end{tikzpicture} 
\end{document}

2 Answers 2

3

Add the libraries decorations.pathreplacing and calc to your preamble, along with the following tikzset:

\tikzset{nsenwarrows/.style={decorate, decoration={show path construction,
    lineto code={
        \path (\tikzinputsegmentfirst); \pgfgetlastxy{\xstart}{\ystart};
        \path (\tikzinputsegmentlast); \pgfgetlastxy{\xend}{\yend};
        \path ($(0,0)!1.5pt!(\ystart-\yend,\xend-\xstart)$); \pgfgetlastxy{\xperp}{\yperp}; 
        \draw[->, shift={($(-\xperp,-\yperp)$)}, shorten <=1.5pt, shorten >=1.5pt, #1] (\xstart,\ystart)--(\xend,\yend);
        \draw[->, shift={(\xperp,\yperp)}, shorten <=1.5pt, shorten >=1.5pt, #1] (\xend,\yend)--(\xstart,\ystart);
        \draw[#1] ($.5*(\xstart,\ystart)+.5*(\xend,\yend)+4*(\xperp,\yperp)$)--($.5*(\xstart,\ystart)+.5*(\xend,\yend)-4*(\xperp,\yperp)$);
    }}}, nsenwarrows/.default={}
}

Then you can use the key nsenwarrows in \draw statements to produce the negated arrows between nodes. For example:

\draw[nsenwarrows] (abi) to node[below left]{exogeneity} (qob);
\draw[nsenwarrows=red] (abi) to (sch);

enter image description here

Here is the complete code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, arrows.meta}
\usetikzlibrary{decorations.pathreplacing, calc}

\tikzset{nsenwarrows/.style={decorate, decoration={show path construction,
    lineto code={
        \path (\tikzinputsegmentfirst); \pgfgetlastxy{\xstart}{\ystart};
        \path (\tikzinputsegmentlast); \pgfgetlastxy{\xend}{\yend};
        \path ($(0,0)!1.5pt!(\ystart-\yend,\xend-\xstart)$); \pgfgetlastxy{\xperp}{\yperp}; 
        \draw[->, shift={($(-\xperp,-\yperp)$)}, shorten <=1.5pt, shorten >=1.5pt, #1] (\xstart,\ystart)--(\xend,\yend);
        \draw[->, shift={(\xperp,\yperp)}, shorten <=1.5pt, shorten >=1.5pt, #1] (\xend,\yend)--(\xstart,\ystart);
        \draw[#1] ($.5*(\xstart,\ystart)+.5*(\xend,\yend)+4*(\xperp,\yperp)$)--($.5*(\xstart,\ystart)+.5*(\xend,\yend)-4*(\xperp,\yperp)$);
    }}}, nsenwarrows/.default={}
}

\begin{document}
\begin{tikzpicture}
\node at (0,0) (qob) {Quarter of Birth};
\node[right=1cm of qob] (sch) {Schooling};
\node[right=1cm of sch] (wage) {Wage};
\node[below=1cm of sch] (abi) {Ability $\in \:u$};

\draw[nsenwarrows=red] (abi) to (sch);
\draw[->] (abi) to (wage);
\draw[->] (qob) to (sch); %here I want to have "relevance" above the arrow
\draw[->] (sch) to (wage); %here i want a "?" above the arrow
\draw[nsenwarrows] (abi) to node[below left]{exogeneity} (qob); %here I want to replace the arrow with \nsenwarrows and write "exogeneity" below

\end{tikzpicture} 
\end{document}

As an alternative, this is easier with tikz-cd. Define a macro \nsenwarrows that takes one required argument (direction) and one optional argument (label). For example,

\nsenwarrows[\textup{\scriptsize exogeneity}]{ul}

will draw the arrow from the current cell up-left with the given label.

enter image description here

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

\newcommand{\nsenwarrows}[2][]{\arrow[#2, shift left=2pt, shorten=2mm, "|"marking, "#1", outer sep=1mm]\arrow[#2, shift right=2pt, <-, shorten=2mm, "|"marking]}

\begin{document}
\begin{tikzcd}[column sep=1.5cm, row sep=1cm]
\textup{Quarter of Birth}\arrow[r, "\textup{\scriptsize relevance}"] & \textup{Schooling}\arrow[r, "?"] & \textup{Wage}\\
 & \textup{Ability}\in u\arrow[ur]\arrow[u, red]\nsenwarrows[\textup{\scriptsize exogeneity}]{ul}
\end{tikzcd} 
\end{document}
3
  • Thank you for your answer! However for my use case this is a "worst case"-solution. A feature of tikzpicture that I value is that when using node and draw it is very clear which part of the code does what. That makes it easier to use in when collaborating with others, which I do on this project (should have clarified that earlier).
    – AoMRos
    Commented Nov 20, 2022 at 13:26
  • @AoMRos: I added a solution that is more portable, without tikz-cd. Does that do what you want?
    – Sandy G
    Commented Nov 20, 2022 at 17:06
  • I believe that will be perfect! Thank you so very much!
    – AoMRos
    Commented Nov 20, 2022 at 18:53
4

The name of the symbol is \nsenwarrows and it can be found in fdsymbol and MnSymbol packages. To have the symbol between nodes just load a package that include the symbol and insert it as a node between those you want to have it between them. You can get some initial ideas from the code below:

\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage{tikz,fdsymbol,xcolor}
\begin{document}
    \begin{tikzpicture}
        \node at (0,0) {Quarter of Birth};
        \draw[very thick,->] (2,0) -- (4,0) node[above,midway] {\footnotesize relevance};
        \node at (5,0) {Schooling};
        \draw[very thick,->] (6,0) -- (8,0) node[above,midway] {?};
        \node at (9,0) {Wage};
        \node at (3,-0.5) {\Large $\nsenwarrows$};\node at (3,-1) {\footnotesize exogeneity};
        \node at (7,-0.5) {\color{red}\large $\uparrow$}; \node at (7,-1) {Ability $\in u$};
        \draw[very thick,->] (8.1,-0.9) -- (9,-0.3);
    \end{tikzpicture}
\end{document}
3
  • Thank you for your comment. Not exactly what I'm looking for though. I want to be able to simply draw the arrows using to rather than having to write coordinates. This is because using coordinates will quickly become way to cumbersome in the later stages of my project. I need the signs and words above/below the arrows to "follow" them. Preferably by everything in the same \draw-command.
    – AoMRos
    Commented Nov 18, 2022 at 13:16
  • @AoMRos You can just use the node with that symbol a path between nodes that's not drawn as the other nodes that are placed midway and sloped. Commented Nov 18, 2022 at 21:17
  • I'm afraid that I don't understand how you mean. Bear in mind that I'm a LaTex-novice. Thank you for your reply though. :)
    – AoMRos
    Commented Nov 21, 2022 at 10:14

You must log in to answer this question.

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