Graphics, Figures & TablesFilling up double Arrows

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Thomas_l
Posts: 6
Joined: Fri Apr 19, 2013 3:13 pm

Filling up double Arrows

Post by Thomas_l »

Hi all,

I'm modifying a piece of code (http://www.texample.net/tikz/examples/double-arrows/) to make my own drawing. But I wanted to change the color of the arrows so I changed the code to this.

Code: Select all

\documentclass{article}
\usepackage{tikz}

\usepackage{verbatim}
\usepackage[active,tightpage]{preview}

\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{10pt}

\usetikzlibrary{arrows, decorations.markings}

\tikzstyle{vecArrow} = [thick, decoration={markings,mark=at position
   1 with {\arrow[semithick]{open triangle 60}}},
   double distance=1.4pt, shorten >= 5.5pt,
   preaction = {decorate},
   postaction = {draw,line width=1.4pt, white,shorten >= 4.5pt}]
\tikzstyle{innerWhite} = [semithick, white,line width=1.4pt, shorten >= 4.5pt]
\tikzstyle{innerGreen} = [semithick, green,line width=1.4pt, shorten >= 4.5pt]

\begin{document}

\begin{tikzpicture}[thick, node distance = 2 cm]
  \node[draw,rectangle] (energieAanvoer) {energieAanvoer};
  \node[inner sep=0,minimum size=0,below of=energieAanvoer] (kruispunt) {}; % invisible node
  \node[draw,rectangle,below of=kruispunt] (energieAfvoer) {energieAfvoer};
  \node[draw,rectangle,right of=kruispunt, node distance = 3cm] (energieOpslag) {energieOpslag};
  \node[draw,rounded corners = 7, rectangle,left of = kruispunt](energieRegeling){energieRegeling};

  % 1st pass: draw arrows
  \draw[vecArrow] (energieAanvoer) to (energieAfvoer);
  \draw[vecArrow] (kruispunt) |- (energieOpslag);
  \draw[vecArrow, bend left = 30] (energieOpslag.south) to (energieAfvoer.east);

  % 2nd pass: copy all from 1st pass, and replace vecArrow with innerWhite
  \draw[innerWhite] (energieAanvoer) to (energieAfvoer);
  \draw[innerGreen] (kruispunt) |- (energieOpslag);
  \draw[innerGreen, bend left = 30] (energieOpslag.south) to (energieAfvoer.east);

  %verbinding met energielevering
  \draw[bend right=10,dotted](energieAanvoer.west) to (energieRegeling.north);
  \draw[bend right,dotted](energieOpslag.north west) to (energieRegeling);
  \draw[bend left=10, dotted](energieAfvoer.west) to (energieRegeling.south);
  
  % Note: If you have no branches, the 2nd pass is not needed
\end{tikzpicture}

\end{document}
But this only changes part of the arrow to green.
Can someone help with this?

Regards
Thomas
Last edited by localghost on Wed Jun 26, 2013 9:53 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Klausiber
Posts: 16
Joined: Sun Apr 14, 2013 11:41 pm

Filling up double Arrows

Post by Klausiber »

Thomas_l wrote:But this only changes part of the arrow to green.
Can someone help with this?
You are using open triangles, which are always white. That's why they are called "open". If you want the whole filling to be green, you will have to use filled triangles as well and set their fill color to green. The 2nd pass is only necessary when there are branches:

Code: Select all

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.markings}

\tikzstyle{vecArrowWhite} = [thick, decoration={markings,mark=at position
   1 with {\arrow[semithick]{open triangle 60}}},
   double distance=1.4pt, shorten >= 5.5pt,
   preaction = {decorate},
   postaction = {draw,line width=1.4pt, white, shorten >= 4.5pt}]
\tikzstyle{vecArrowGreen} = [thick, decoration={markings, mark=at position
   1 with {\arrow[semithick, fill=green]{triangle 60}}},
   double distance=1.4pt, shorten >= 5.5pt,
   preaction = {decorate},
   postaction = {draw, line width=1.4pt, green, shorten >= 4.5pt}]
\tikzstyle{innerWhite} = [semithick, white,line width=1.4pt, shorten >= 4.5pt]
\tikzstyle{innerGreen} = [semithick, green, line width=1.4pt, shorten >= 4.5pt]

\begin{document}

\begin{tikzpicture}[thick, node distance = 2 cm]
  \node[draw,rectangle] (energieAanvoer) {energieAanvoer};
  \node[inner sep=0,minimum size=0,below of=energieAanvoer] (kruispunt) {}; % invisible node
  \node[draw,rectangle,below of=kruispunt] (energieAfvoer) {energieAfvoer};
  \node[draw,rectangle,right of=kruispunt, node distance = 3cm] (energieOpslag) {energieOpslag};
  \node[draw,rounded corners = 7, rectangle,left of = kruispunt](energieRegeling){energieRegeling};

  % 1st pass
  \draw[vecArrowWhite] (energieAanvoer) to (energieAfvoer);
  \draw[vecArrowGreen] (kruispunt) |- (energieOpslag);
  \draw[vecArrowGreen, bend left = 30] (energieOpslag.south) to (energieAfvoer.east);

  % 2nd pass
  \draw[innerWhite] (energieAanvoer) to (energieAfvoer);
  \draw[innerGreen] (kruispunt) |- (energieOpslag);

  %verbinding met energielevering
  \draw[bend right=10,dotted](energieAanvoer.west) to (energieRegeling.north);
  \draw[bend right,dotted](energieOpslag.north west) to (energieRegeling);
  \draw[bend left=10, dotted](energieAfvoer.west) to (energieRegeling.south);

  % Note: If you have no branches, the 2nd pass is not needed
\end{tikzpicture}

\end{document}
The strange thing is that the whole triangle decoration fails for certain bend right values. I tried with 45 because that would give a better transition from the node to the arrow, but then TikZ simple omits the triangle. A bug?
Post Reply