2

Consider the following MWE:

\documentclass[tikz]{standalone}
\usepackage{xcolor}
\usetikzlibrary{calc,positioning,arrows.meta,quotes}
\begin{document}
    \begin{tikzpicture}
    \node[rectangle, draw=black, inner sep=.4cm](nCrystal) at (0,0) {Crys};
    \coordinate(pO) at ($(nCrystal.west)-(4,0)$);
    \coordinate(sO) at ($(nCrystal.west)-(2,1)$);
    \coordinate(pE) at ($(nCrystal.east)+(4,0)$);
    \coordinate(sE) at ($(nCrystal.east)+(2,1)$);
    \coordinate(iE) at ($(nCrystal.east)+(1.5,-0.92815)$);
    \coordinate[right=of nCrystal](cright);
    \draw [-{Latex[width=4mm]},tips=proper,color=green,line width=2mm] (pO) edge["p"] (nCrystal.west);
    \draw [-{Latex},tips=proper,color=red, line width=.2mm] (sO) edge["s"] (nCrystal.west);
    \draw [-{Latex[]},tips=proper,color=green,line width=.5mm] (nCrystal.east) edge["p"] (pE);
    \draw [-{Latex[width=3mm]},tips=proper,color=red,line width=1.7mm] (nCrystal.east) edge["s"] (sE);
    \draw [-{Latex[width=3mm]},tips=proper,color=pink,line width=1.5mm] (nCrystal.east) edge["i"] (iE);
    \end{tikzpicture}
\end{document}

produced output

I have the following questions:

  1. How can I get the first arrow (fat green, labeled "p") to end at the box (just like the red arrow does)

  2. Why is the fourth (fat red) arrow tip looking so badly?

  3. Is here actually a possibility to let the arrow tip scale automatically with the line width but with a smaller factor than the standard (same arrow head for thin lines but for larger lines the default is too thick for me)

I know that asking multiple questions is problematic but they seem to be connected to each other (definitely the latter two are!). Any help is appreciated!

1 Answer 1

2

This is an interesting question. I could not understand properly how the keys length and width work but I noticed that using the option angle=<angle>:<dimension><line width factor> you may obtain the result you want and it also answers all of your questions.

Option angle in arrows library

I copy the definition of the above's option from the TikZ documentation:

This key sets the length and the width of an arrow tip at the same time. 
The length will be the cosine of <angle>, while the width will be twice
the sine of half the <angle>

I've assigned the valued angle=45:5pt 2 to all the arrows based on your question 3 (i.e. scaling according to the line width, in this case by a factor "2", by default it is 4.5). You can adjust those values as you wish:

\documentclass[tikz]{standalone}
\usetikzlibrary{calc,positioning,arrows.meta,quotes}
\begin{document}
    \begin{tikzpicture}[>={Latex[angle=45:5pt 2]}]
    \node[rectangle, draw=black, inner sep=.4cm](nCrystal) at (0,0) {Crys};
    \coordinate(pO) at ($(nCrystal.west)-(4,0)$);
    \coordinate(sO) at ($(nCrystal.west)-(2,1)$);
    \coordinate(pE) at ($(nCrystal.east)+(4,0)$);
    \coordinate(sE) at ($(nCrystal.east)+(2,1)$);
    \coordinate(iE) at ($(nCrystal.east)+(1.5,-0.92815)$);
    \coordinate[right=of nCrystal](cright);
    \draw [->,tips=proper,color=green,line width=2mm] (pO) edge["p"] (nCrystal.west);
    \draw [->,tips=proper,color=red, line width=.2mm] (sO) edge["s"] (nCrystal.west);
    \draw [->,tips=proper,color=green,line width=.5mm] (nCrystal.east) edge["p"] (pE);
    \draw [->,tips=proper,color=red,line width=1.7mm] (nCrystal.east) edge["s"] (sE);
    \draw [->,tips=proper,color=pink,line width=1.5mm] (nCrystal.east) edge["i"] (iE);
    \end{tikzpicture}
\end{document}

Just a quick note, tikz loads xcolor automatically so no need to add \usepackage{xcolor} in the preamble.

1
  • I guess I didn't see this while skimming the pgfmanual section on arrow tips because of the somewhat misleading name. Thanks for pointing it out, I'm happy with this solution! Commented Mar 8, 2016 at 15:33

You must log in to answer this question.

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