0

I'd like to visualize the KS-type proof by Mermin on p. 17 in arXiv:1802.10119 by using colored thick lines below the node descriptions and not on the descriptions. But in my code, the lines cover the descriptions and I don't know how to fix it. Additionally it would be nice if the lines would not stop before the node description, such that the pentagram can be seen completely. I'm not very familiar with tikz, therefore I positioned the nodes manually, which is okay - but I hope someone could help me with the coloring problem and making this picture look neater.

The code so far:

\begin{tikzpicture}
\node(A)[draw=none,fill=none] at (0,0.5) {$\sigma^1_y$};
\node(B)[draw=none,fill=none] at (-0.8,-1){$\sigma_y^1\sigma_x^2\sigma_y^3$};
\node(C)[draw=none,fill=none] at (0.8,-1){$\sigma_y^1\sigma_y^2\sigma_x^3$};
\node(D)[draw=none,fill=none] at (2.4,-1){$\sigma_x^1\sigma_y^2\sigma_y^3$};
\node(E)[draw=none,fill=none] at (-2.4,-1){$\sigma_x^1\sigma_x^2\sigma_x^3$};
\node(F)[draw=none,fill=none] at (1.1,-1.9){$\sigma_y^3$};
\node(G)[draw=none,fill=none] at (-1.1,-1.9){$\sigma_x^3$};
\node(H)[draw=none,fill=none] at (0,-2.6){$\sigma_x^1$};
\node(I)[draw=none,fill=none] at (-2,-4){$\sigma_y^2$};
\node(J)[draw=none,fill=none] at (2,-4){$\sigma_x^2$};

\draw[magenta,thick](A)--(J);
\draw[magenta,thick](A)--(I);
\draw[magenta,thick](E)--(J);
\draw[magenta,thick](D)--(I);
\draw[blue,thick](D)--(E);
\end{tikzpicture}

Crappy result I got so far.

3 Answers 3

2

If you want to improve the node positions you can also use the intersections library and the backgrounds library to make sure the lines are in the background:

\documentclass[tikz]{standalone}
\usetikzlibrary{backgrounds,calc,intersections}

\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0.5);
\coordinate (J) at (2,-4);
\coordinate (E) at (-2.4,-1);
\coordinate (D)at (2.4,-1);
\coordinate (I) at (-2,-4);

\path[name path = de] (D)--(E);
\path[name path=aj] (A) -- (J);
\path[name path = ai] (A) -- (I);
\path[name path =di] (D) --(I) ;
\path[name path =ej] (E) --(J);
\path[name intersections ={of = aj and de,by=B}] ;
\path[name intersections ={of = ai and de,by=C}] ;
\path[name intersections = {of=aj and di,by=F}];
\path[name intersections = {of =ai and ej,by=G}];
\path[name intersections = {of =di and ej,by=H}];

\node at (C) {C};
\node at (B) {B};
\node at (F){F};
\node at (G){G};
\node at (H){H};

\begin{pgfonlayer}{background}
\draw[magenta,thick] (I) -- (A) node[black] {$\sigma^1_y$}--(J) node [black]{J}-- (E) node [black]{E} -- (D) node [black]{D} -- (I) node [black]{I};
\draw[blue,thick](D)--(E);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}

enter image description here

(EDIT to the image: replaced the image with an image using the acutal colors.)

EDIT: Now that I can properly do this at a stationary device, I removed some of the redudancies of the code and used polar coordinates to ensure a regular pentagramm. Also, I changed node labels to be more mathematical.

\documentclass[tikz]{standalone}
\usetikzlibrary{backgrounds,calc,intersections}

\begin{document}
    \begin{tikzpicture}
        \foreach \i/\j in {0/A, 1/B, 2/C, 3/D, 4/E}{
            \coordinate (\j) at ({90+72*\i}:2cm);
            }
        
        \path[name path = ac] (A) -- (C);
        \path[name path = ad] (A) -- (D);
        \path[name path = be] (B) -- (E);
        \path[name path = bd] (B) -- (D);
        \path[name path = ce] (E) -- (C);
        
        \node[name intersections = {of = ad and be,by=F}] at (F) {F};
        \node[name intersections = {of = ac and be,by=G}] at (G) {G};
        \node[name intersections = {of = ac and bd,by=H}] at (H) {H};
        \node[name intersections = {of = ce and bd,by=I}] at (I) {I};
        \node[name intersections = {of = ad and ce,by=J}] at (J) {J};
        
        \begin{pgfonlayer}{background}
            \begin{scope}[every node/.style={black}]
                \draw[magenta,thick] (A) node {A} -- (C) node {C} -- (E) node {E} -- (B) node {B} -- (D) node {D} -- cycle;
                \draw[blue,thick] (B)--(E);
            \end{scope}
        \end{pgfonlayer}
    \end{tikzpicture}
\end{document}

enter image description here

I should point out that it is of course not very nice having to draw the blue line again, on top of the magenta line, but unfortunately that is necessary to obtain the pointy edges. Changing the color for only a section of such a path is a bit more complicated and has been answered in great detail for this question: TikZ: changing colour of a path half way along

3
  • Thank you!!! This is nearly exactly that what I was looking for:)
    – Juri V
    Jun 13, 2021 at 12:30
  • I added a more efficient version of the code. If you tell me, what else is missing for you, add a comment and maybe I can help you more.
    – Markus G.
    Jun 14, 2021 at 9:36
  • Thanks! I'm happy now,! Yesterday I already edited my answer using your code and adding polar coordinates from José's earlier code. Additionally I decided to use white filling because it improves readability I guess (maybe I'll remove it again, I will see), therefore it doesn't pose a problem that the blue line is drawn separately!:)
    – Juri V
    Jun 14, 2021 at 11:16
2

With this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[scale=4]
\foreach \x in{0,...,4} \coordinate (A\x) at ({sin(\x*72)},{cos(\x*72)});
\draw[name path=A02,thick,color=magenta] (A0)--(A2);
\draw[name path=A03,thick,color=magenta] (A0)--(A3);
\draw[thick,color=magenta] (A4)--(A2);
\draw[thick,color=magenta] (A3)--(A1);
\draw[name path=A14,thick,blue] (A4)--(A1);
\path[name intersections={of=A02 and A14,by=Ir}];
\path[name intersections={of=A03 and A14,by=Il}];
\node[above] at (A0) {$\sigma_y^1$};
\node[right] at (A1) {$\sigma_x^1\sigma_y^2\sigma_y^3$};
\node[below right] at (A2) {$\sigma_x^2$};
\node[below left] at (A3) {$\sigma_y^2$};
\node[left] at (A4) {$\sigma_x^1\sigma_x^2\sigma_x^3$};
\node[above right] at (Ir) {$\sigma_y^1\sigma_x^2\sigma_y^3$};
\node[above left] at (Il) {$\sigma_y^1\sigma_y^2\sigma_x^3$};
\end{tikzpicture}
\end{document}

I got this:

enter image description here

2
  • 1
    Nice thanks! I guess I will somehow make an hybrid out of your and my solution, then there will be less redundant code and the result will be as I wanted it to be I hope:)
    – Juri V
    Jun 13, 2021 at 12:21
  • I've edited my answer. The final result is the same, but now the coordinates of the points Il and Ir are computed by TikZ itself. Jun 13, 2021 at 14:17
0

Now it's beautiful, at least I'm happy with the result. I added white filling for better readability.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{backgrounds,calc,intersections}

\begin{document}
\begin{tikzpicture}[scale=4]
\foreach \x in{0,...,4} \coordinate (A\x) at ({sin(\x*72)},{cos(\x*72)});
\path[name path = a1] (A0)--(A2);
\path[name path=a2] (A0) -- (A3);
\path[name path = a3] (A4) -- (A2);
\path[name path =a4] (A3) --(A1) ;
\path[name path =a5] (A4) --(A1);
\path[name intersections ={of = a2 and a3,by=B1}] ;
\path[name intersections ={of = a5 and a1,by=B2}] ;
\path[name intersections = {of=a3 and a4,by=B3}];
\path[name intersections = {of =a1 and a4,by=B4}];
\path[name intersections = {of =a5 and a2,by=B5}];


\node [black,rectangle,fill=white] at (B1) {$\sigma_x^3$};
\node [black,rectangle,fill=white] at (B2) {$\sigma_y^1\sigma_x^2\sigma_y^3$};
\node [black,rectangle,fill=white] at (B3){$\sigma_x^1$};
\node [black,rectangle,fill=white] at (B4){$\sigma_y^3$};
\node [black,rectangle,fill=white] at (B5){$\sigma_y^1\sigma_y^2\sigma_x^3$};

\begin{pgfonlayer}{background}
\draw[magenta,line width=1mm] (A0) -- (A2) node[black,rectangle,fill=white] {$\sigma_x^2$}--(A4) -- (A1)  -- (A3) node [black,rectangle,fill=white]{$\sigma_y^2$} -- (A0) node [black,rectangle,fill=white]{$\sigma_y^1$};
\draw[blue,line width=1mm](A4)node [black,rectangle,fill=white]{$\sigma_x^1\sigma_x^2\sigma_x^3$}--(A1)node [black,rectangle,fill=white]{$\sigma_x^1\sigma_y^2\sigma_y^3$};
\end{pgfonlayer}

\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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