5

How can I get the dash-dotted line to appear between the other two?

enter image description here

Currently, both lines are anchored to "A.north west" (and the regular dashed line is effectively at "A.north"). If I anchor the dotted line to "A.west", they are all separate (good!), but I don't want it to meet the node that low, and I like "A.north west" as the leftmost position (for the dotted line).

Is there a way to anchor the line to something akin to "A.north north west"?

My code:

\documentclass[tikz]{standalone}
\usepackage{bbding} % For checkmark & ballot X

\begin{document}

\begin{tikzpicture}[fatnode/.style={circle, fill=blue!20}]
    \node[fatnode] (A) at (0, 0) {\textbf{A}};
    \node[fatnode] (B) at (1.5, 0) {\textbf{B}};
    \node[fatnode] (C) at (3, 0) {\textbf{C}};
    \node[fatnode] (D) at (4.5, 0) {\textbf{D}};
    \node[fatnode] (E) at (6, 0) {\textbf{E}};

    \draw[<->, thick] (A) to node[auto] {\Checkmark} (B);
    \draw[<->, thick] (B) to node[auto] {\Checkmark} (C);
    \draw[<->, thick] (C) to node[auto] {\Checkmark} (D);                
    \draw[<->, thick] (D) to node[auto] {\Checkmark} (E);

    \draw[<->, thick, dashed] (A) |- (1, .75) -| (C);
    \node (a) at (1.5, 1.1) {\textbf{(\Checkmark)}};

    \draw[<->, thick, dash dot dot] (A.north west) |- (1, 1.75) -| (D);
    \node (b) at (2.25, 2) {\textbf{?}};
    
    \draw[<->, thick, loosely dotted] (A.north west) |- (1, 2.5) -| (E);
    \node (c) at (3, 2.75) {\textbf{\XSolidBrush}};
\end{tikzpicture}

\end{document}
New contributor
Andrew is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
6
  • 1
    You can specify the angle. This allows you to fine-tune the position. Can you make a compilable test file? May 14 at 8:55
  • 2
    (A.112.5) should work. North is A.90, north west is A.135, the middle is A.112.5.
    – CarLaTeX
    May 14 at 8:58
  • I edited to include the full code. The solution w/ the degrees works beautifully! Thank you!
    – Andrew
    May 14 at 9:36
  • @CarLaTeX It would be nice to see your comment as an answer! May 14 at 9:52
  • 1
    @samcarter_is_at_topanswers.xyz I'll do it asap, if you don't prefer to add one yourself
    – CarLaTeX
    May 14 at 10:03

3 Answers 3

9

Since AndréC already answered following my comment, I suggest another appearance:

\documentclass[tikz,border=5mm]{standalone}
\usepackage{bbding}% For checkmark & ballot X

\tikzset{
  my arrow/.style={to path={-- ++(0,#1) -| (\tikztotarget)\tikztonodes}},
  fatnode/.style={circle, fill=blue!20},
  descrnode/.style={near start,above, font=\bfseries},
  }
  
\begin{document}
\begin{tikzpicture}
  \foreach \point [count=\position, evaluate=\point as \x using \position*1.5]in {A,...,E}
     \node[fatnode] (\point) at (\x, 0) {\textbf{\point}};
  \foreach \point  [remember=\point as \last (initially A)] in {B,...,E}
    \draw[<->, thick] (\last) to node[auto] {\Checkmark} (\point);
  \draw[my arrow=.75, <->, thick, dashed] (A) to node[descrnode]{(\Checkmark)}(C);
  \draw[<->, thick, dash dot dot] (A.north west) to ++(-.25,.3) to ++(0,1.2) -| node[descrnode] {?} (D);   
  \draw[<->, thick, loosely dotted] (A.west) to ++(-.5,0) to ++(0,2.5) -| node[descrnode]{\XSolidBrush} (E.north);
\end{tikzpicture}
\end{document}

enter image description here

4
  • This looks nice! No so crowed as with all the arrows from the same side. May 14 at 13:55
  • @samcarter_is_at_topanswers.xyz Yes, I think it's aesthetically better :D
    – CarLaTeX
    May 14 at 13:57
  • It also makes it very easy for the eye to follow each line. May 14 at 13:57
  • @samcarter_is_at_topanswers.xyz that, too!
    – CarLaTeX
    May 14 at 13:58
7

As indicated in the comments, you can use angles in this case because the nodes are circles and the angles are calculated considering that the nodes are circles (but not rectangles). Knowing that north=90° and west=180°. You can easily calculate the values you want.

I used a foreach loop to define points A, B, C, D and E:

\foreach \point [count=\position, evaluate=\point as \x using \position*1.5]in {A,...,E}
     \node[fatnode] (\point) at (\x, 0) {\textbf{\point}};

I've reduced the code too with a foreach loop to draw the double arrows between points A,B,C, D and E.

\foreach \point  [remember=\point as \last (initially A)] in {B,...,E}
    \draw[<->, thick] (\last) to node[auto] {\Checkmark} (\point);

I added a style with a parameter to draw the paths between these points. This style places the text above the path.

\tikzset{my arrow/.style={to path={-- ++(0,#1) -| (\tikztotarget)\tikztonodes}}}

Complete code:

\documentclass[tikz,border=5mm]{standalone}
\usepackage{bbding} % For checkmark & ballot X

\tikzset{my arrow/.style={to path={-- ++(0,#1) -| (\tikztotarget)\tikztonodes}}}
\begin{document}

\begin{tikzpicture}[fatnode/.style={circle, fill=blue!20}]
\foreach \point [count=\position, evaluate=\point as \x using \position*1.5]in {A,...,E}
     \node[fatnode] (\point) at (\x, 0) {\textbf{\point}};

\foreach \point  [remember=\point as \last (initially A)] in {B,...,E}
    \draw[<->, thick] (\last) to node[auto] {\Checkmark} (\point);

    \draw[my arrow=.75,<->, thick, dashed] (A) to node[near start,above]{\textbf{(\Checkmark)}}(C);
    \draw[my arrow=1.5,<->, thick, dash dot dot] (A.112.5)  to node[near start,above] {\textbf{?}} (D);   
    \draw[my arrow=2.5,<->, thick, loosely dotted] (A.north west) to node[near start,above]{\textbf{\XSolidBrush}} (E);

\end{tikzpicture}

\end{document}

enter image description here

-1
\documentclass[tikz,border=5mm]{standalone}
\usepackage{bbding}% For checkmark & ballot X

\tikzset{
  my arrow/.style={to path={-- ++(0,#1) -| (\tikztotarget)\tikztonodes}},
  fatnode/.style={circle, fill=blue!20},
  descrnode/.style={near start,above, font=\bfseries},
  }
  
\begin{document}
\begin{tikzpicture}
  \foreach \point [count=\position, evaluate=\point as \x using \position*1.5]in {A,...,E}
     \node[fatnode] (\point) at (\x, 0) {\textbf{\point}};
  \foreach \point  [remember=\point as \last (initially A)] in {B,...,E}
    \draw[<->, thick] (\last) to node[auto] {\Checkmark} (\point);
  \draw[my arrow=.75, <->, thick, dashed] (A) to node[descrnode]{(\Checkmark)}(C);
  \draw[<->, thick, dash dot dot] (A.north west) to ++(-.25,.3) to ++(0,1.2) -| node[descrnode] {?} (D);   
  \draw[<->, thick, loosely dotted] (A.west) to ++(-.5,0) to ++(0,2.5) -| node[descrnode]{\XSolidBrush} (E.north);
\end{tikzpicture}
\end{document} 

\draw [answer AtoE is 7]

New contributor
Raja is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • 1
    Welcome to TeX.SE!This seems to be copy of @CarLaTeX answer. Please extend your answer with some explanation (how your answer differ from other).
    – Zarko
    2 days ago

You must log in to answer this question.

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