1

I'm generating a PDF file from the following simple tikzfigure description using pdflatex.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,backgrounds}

\begin{document}

\begin{tikzpicture}
\foreach \x in {0,...,7} {
    \node (n\x0) at (2*\x,0) {Thread \x};
    \node (n01) [font=\scriptsize] at (0,-4) {Thread 0,4};
    \node (n11) [font=\scriptsize] at (2,-4) {Thread 1,5};
    \node (n21) [font=\scriptsize] at (4,-4) {Thread 2,6};
    \node (n31) [font=\scriptsize] at (6,-4) {Thread 3,7};
    \node (n02) [font=\tiny] at (0,-8) {Thread 0,2,4,6};
    \node (n12) [font=\tiny] at (2,-8) {Thread 1,3,5,7};
    \node (n03) at (0,-12) {Block};
}

\node (p1) [circle,fill=white] at (0,-2.5) {+};
\node (p2) [circle,fill=white] at (2,-2.5) {+};
\node (p3) [circle,fill=white] at (4,-2.5) {+};
\node (p4) [circle,fill=white] at (6,-2.5) {+};
\node (p5) [circle,fill=white] at (0,-6.5) {+};
\node (p6) [circle,fill=white] at (2,-6.5) {+};
\node (p7) [circle,fill=white] at (0,-10.5) {+};

\begin{scope}[on background layer]
    \draw [-{Stealth[scale=1.5]}] (n00.south) -- (p1.north);
    \draw [-{Stealth[scale=1.5]}] (n10.south) -- (p2.north);
    \draw [-{Stealth[scale=1.5]}] (n20.south) -- (p3.north);
    \draw [-{Stealth[scale=1.5]}] (n30.south) -- (p4.north);
    \draw [-{Stealth[scale=1.5]}] (n40.south) -- (p1.north);
    \draw [-{Stealth[scale=1.5]}] (n50.south) -- (p2.north);
    \draw [-{Stealth[scale=1.5]}] (n60.south) -- (p3.north);
    \draw [-{Stealth[scale=1.5]}] (n70.south) -- (p4.north);
    \draw [-{Stealth[scale=1.5]}] (p1) -- (n01);
    \draw [-{Stealth[scale=1.5]}] (p2) -- (n11);
    \draw [-{Stealth[scale=1.5]}] (p3) -- (n21);
    \draw [-{Stealth[scale=1.5]}] (p4) -- (n31);
    \draw [-{Stealth[scale=1.5]}] (n01.south) -- (p5.north);
    \draw [-{Stealth[scale=1.5]}] (n11.south) -- (p6.north);
    \draw [-{Stealth[scale=1.5]}] (n21.south) -- (p5.north);
    \draw [-{Stealth[scale=1.5]}] (n31.south) -- (p6.north);
    \draw [-{Stealth[scale=1.5]}] (p5) -- (n02);
    \draw [-{Stealth[scale=1.5]}] (p6) -- (n12);
    \draw [-{Stealth[scale=1.5]}] (n02.south) -- (p7.north);
    \draw [-{Stealth[scale=1.5]}] (n12.south) -- (p7.north);
    \draw [-{Stealth[scale=1.5]}] (p7) -- (n03);
\end{scope}
\end{tikzpicture}

\end{document}

The figure itself looks as expected, the only thing that bothers me is that the labels of all nodes in every row except the first does not seem to be smoothed properly (this might be hard to see in the .png attached below but it is definitely obvious in the original PDF).

enter image description here

Can anybody else reproduce this issue? Is pdflatex the cause or is there something wrong with the code itself?

5

The problem is that you print the same text 8 times above each other. Small inaccuracies will result in the "grainy" look.

To solve the problem move all static elements outside the loop.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,backgrounds}

\begin{document}

\begin{tikzpicture}
\foreach \x in {0,...,7} {
    \node (n\x0) at (2*\x,0) {Thread \x};
 }
    \node (n01) [font=\scriptsize] at (0,-4) {Thread 0,4};
    \node (n11) [font=\scriptsize] at (2,-4) {Thread 1,5};
    \node (n21) [font=\scriptsize] at (4,-4) {Thread 2,6};
    \node (n31) [font=\scriptsize] at (6,-4) {Thread 3,7};
    \node (n02) [font=\tiny] at (0,-8) {Thread 0,2,4,6};
    \node (n12) [font=\tiny] at (2,-8) {Thread 1,3,5,7};
    \node (n03) at (0,-12) {Block};


\node (p1) [circle,fill=white] at (0,-2.5) {+};
\node (p2) [circle,fill=white] at (2,-2.5) {+};
\node (p3) [circle,fill=white] at (4,-2.5) {+};
\node (p4) [circle,fill=white] at (6,-2.5) {+};
\node (p5) [circle,fill=white] at (0,-6.5) {+};
\node (p6) [circle,fill=white] at (2,-6.5) {+};
\node (p7) [circle,fill=white] at (0,-10.5) {+};

\begin{scope}[on background layer]
    \draw [-{Stealth[scale=1.5]}] (n00.south) -- (p1.north);
    \draw [-{Stealth[scale=1.5]}] (n10.south) -- (p2.north);
    \draw [-{Stealth[scale=1.5]}] (n20.south) -- (p3.north);
    \draw [-{Stealth[scale=1.5]}] (n30.south) -- (p4.north);
    \draw [-{Stealth[scale=1.5]}] (n40.south) -- (p1.north);
    \draw [-{Stealth[scale=1.5]}] (n50.south) -- (p2.north);
    \draw [-{Stealth[scale=1.5]}] (n60.south) -- (p3.north);
    \draw [-{Stealth[scale=1.5]}] (n70.south) -- (p4.north);
    \draw [-{Stealth[scale=1.5]}] (p1) -- (n01);
    \draw [-{Stealth[scale=1.5]}] (p2) -- (n11);
    \draw [-{Stealth[scale=1.5]}] (p3) -- (n21);
    \draw [-{Stealth[scale=1.5]}] (p4) -- (n31);
    \draw [-{Stealth[scale=1.5]}] (n01.south) -- (p5.north);
    \draw [-{Stealth[scale=1.5]}] (n11.south) -- (p6.north);
    \draw [-{Stealth[scale=1.5]}] (n21.south) -- (p5.north);
    \draw [-{Stealth[scale=1.5]}] (n31.south) -- (p6.north);
    \draw [-{Stealth[scale=1.5]}] (p5) -- (n02);
    \draw [-{Stealth[scale=1.5]}] (p6) -- (n12);
    \draw [-{Stealth[scale=1.5]}] (n02.south) -- (p7.north);
    \draw [-{Stealth[scale=1.5]}] (n12.south) -- (p7.north);
    \draw [-{Stealth[scale=1.5]}] (p7) -- (n03);
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here

  • ah yes, I didn't even notice that. It looks fine now, thank you. – Peter Jun 12 '18 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.