3

I'm pretty new to Tikz and I'm facing a little issue.

I'd like to draw arrows that are overlapping, all going in same directions, but it's getting wider and wider and is pretty horrible. How could I face it ? Here is the code :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, calc}

\begin{document}
    \begin{tikzpicture}[node distance=2.3cm]
    % Style
    \tikzstyle{cell} = [rectangle, minimum width=1.5cm, minimum height=1.5cm, text centered, draw=black, fill=green!20]
    \tikzstyle{tensor} = [circle, minimum width=1cm, text centered, draw=black, fill=green!10]

    \tikzstyle{arrow} = [thick,->,>=stealth]

    % Nodes

    \node (he)   [tensor] {$h^e$};

    \node (d1)   [cell, right of=he, below of=he, xshift=1.5cm, yshift=-2cm] {$d$};
    \node (d2)   [cell, right of=d1, xshift=1.5cm] {$d$};
    \node (dn)   [cell, right of=d2, xshift=2cm] {$d$};

    \node (w1)   [tensor, above of=d1, left of=d1, minimum width=1.25cm] {$w_1$};
    \node (w2)   [tensor, above of=d2, left of=d2, minimum width=1.25cm] {$w_2$};
    \node (wn)   [tensor, above of=dn, left of=dn, minimum width=1.25cm] {$w_n$};


    % Arrows
    \draw[arrow] (w1) -| (d1);
    \draw[arrow] (w2) -| (d2);
    \draw[arrow] (wn) -| (dn);

    \draw[arrow] (d1) -- (d2);
    \draw[arrow] (he) |- (d1);

    \draw[arrow] (he) -| (d1);
    \draw[arrow] (he) -| (d2);
    \draw[arrow] (he) -| (dn);

\end{tikzpicture}
\end{document}

If you render the figure, you'll see arrows getting darker, how can I fix it ?

Thanks, Cheers

  • Welcome to TeX.Stackexchange! Can you make your example compilable? When I try to run your code I get errors. I can debug them, but how would I know if this still reproduces the problem you are asking about? – samcarter_is_at_topanswers.xyz Jan 23 '19 at 10:26
  • Actually, as I know, if two lines overlapping each other in TikZ, they are darkened. –  Jan 23 '19 at 10:28
  • @samcarter I fixed it, bad copy/paster my bad – Ricocotam Jan 23 '19 at 10:34
  • @joulev That's exactly my problem, I don't want arrows being darkened – Ricocotam Jan 23 '19 at 10:35
  • 1
    Have you tried to print it? There are often aliasing problems with PDF viewers, and the line can seems darker or not depending on the zoom level. – Rmano Jan 23 '19 at 10:45
  • @Rmano You're right, when I zoom there's no difference. But it's a numerical report so the "pdf view" issue is actually an issue. I can't print it right now, I'll try. – Ricocotam Jan 23 '19 at 10:48

2 Answers2

3

The following example uses the calc library to print each line only once. If you still experience problems with varying line widths this is most probably an issue of your pdf viewer.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, calc}

\begin{document}
    \begin{tikzpicture}[node distance=2.3cm]
    % Style
    \tikzset{
        cell/.style={rectangle, minimum width=1.5cm, minimum height=1.5cm, text centered, draw=black, fill=green!20}, 
        tensor/.style={circle, minimum width=1cm, text centered, draw=black, fill=green!10}, arrow/.style={thick,->,>=stealth},
        arrow/.style={thick,->,>=stealth}
    }

    % Nodes

    \node (he)   [tensor] {$h^e$};

    \node (d1)   [cell, right of=he, below of=he, xshift=1.5cm, yshift=-2cm] {$d$};
    \node (d2)   [cell, right of=d1, xshift=1.5cm] {$d$};
    \node (dn)   [cell, right of=d2, xshift=2cm] {$d$};

    \node (w1)   [tensor, above of=d1, left of=d1, minimum width=1.25cm] {$w_1$};
    \node (w2)   [tensor, above of=d2, left of=d2, minimum width=1.25cm] {$w_2$};
    \node (wn)   [tensor, above of=dn, left of=dn, minimum width=1.25cm] {$w_n$};


    % Arrows
    \draw[arrow] (w1) -| (d1);
    \draw[arrow] (w2) -| (d2);
    \draw[arrow] (wn) -| (dn);

    \draw[arrow] (d1) -- (d2);
    \draw[arrow] (he) |- (d1);

    \draw[arrow] (he) -| (d1);
    \draw[arrow] let \p1 = (he), \p2 = (d1) in (\x2,\y1) -| (d2);
    \draw[arrow] let \p1 = (he), \p2 = (d2) in (\x2,\y1) -| (dn);

\end{tikzpicture}
\end{document}

enter image description here

Thanks to @marmot for suggesting this calc free version:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}

\begin{document}
    \begin{tikzpicture}[node distance=2.3cm]
    % Style
    \tikzset{
        cell/.style={rectangle, minimum width=1.5cm, minimum height=1.5cm, text centered, draw=black, fill=green!20}, 
        tensor/.style={circle, minimum width=1cm, text centered, draw=black, fill=green!10}, arrow/.style={thick,->,>=stealth},
        arrow/.style={thick,->,>=stealth}
    }

    % Nodes

    \node (he)   [tensor] {$h^e$};

    \node (d1)   [cell, right of=he, below of=he, xshift=1.5cm, yshift=-2cm] {$d$};
    \node (d2)   [cell, right of=d1, xshift=1.5cm] {$d$};
    \node (dn)   [cell, right of=d2, xshift=2cm] {$d$};

    \node (w1)   [tensor, above of=d1, left of=d1, minimum width=1.25cm] {$w_1$};
    \node (w2)   [tensor, above of=d2, left of=d2, minimum width=1.25cm] {$w_2$};
    \node (wn)   [tensor, above of=dn, left of=dn, minimum width=1.25cm] {$w_n$};


    % Arrows
    \draw[arrow] (w1) -| (d1);
    \draw[arrow] (w2) -| (d2);
    \draw[arrow] (wn) -| (dn);

    \draw[arrow] (d1) -- (d2);
    \draw[arrow] (he) |- (d1);

    \draw[arrow] (he) -| (d1);
        \draw[arrow] (d1|-he) -| (d2); 
        \draw[arrow] (d2|-he) -| (dn);

\end{tikzpicture}
\end{document}
2

This is what I see (okular) at 100% zoom:

enter image description here

so I can't see any "darkening". Now, zooming in:

enter image description here

This is a rendering/aliasing problem for subpixel zooms, and it is mostly unsolvable (it depends on the anti-aliasing algorithm of the viewer).

Rmano
  • 40,848
  • 3
  • 64
  • 125