0

I would like to draw the following picture with the dashed arrows replaced by the crossing overs in xymatrix or in tikz. I drew this one tikz but somehow unable to do the crossing overs.

Any help will be appreciated.

\begin{figure}[hbt]
 \centering
 \scalebox{0.6}
 {
 \begin{tikzpicture}[scale=5]
     \tikzstyle{vertex}=[circle,minimum size=20pt,inner sep=0pt]
     \tikzstyle{selected vertex} = [vertex, fill=blue!24]
     \tikzstyle{selected edge} = [draw,line width=1pt,-,blue!50]
     \tikzstyle{edge} = [draw,line width=3pt,-,white]
     \node[vertex] (v1) at (0,2) {$K(V,0)$};
     \node[vertex] (v2) at (1, 2) {$\binom{V_1}{V}$};
     \node[vertex] (v3) at (0.33, 1.66) {$\binom{V_2}{V}$};
      \node[vertex] (v4) at (0,1) {$\binom{V_3}{V}$};
         \node[vertex] (v5) at (0.33,0.66) {${\begin{psmallmatrix} V_{23}\\
      V_2\oplus V_3\\ V
  \end{psmallmatrix}}$};
     \node[vertex] (v6) at (1,1) {${\begin{psmallmatrix} V_{13}\\
      V_1\oplus V_3\\ V
  \end{psmallmatrix}}$};
     \node[vertex] (v7) at (1.33, 0.66) {${\begin{psmallmatrix} V_{12}\oplus V_{13}\oplus V_{23}\\
      V_1\oplus V_2 \oplus V_3\\ V
  \end{psmallmatrix}}$};
     \node[vertex] (v8) at (1.33, 1.66) {${\begin{psmallmatrix} V_{12}\\
      V_1\oplus V_2\\ V
  \end{psmallmatrix}}$};
         \node[vertex] (v9) at (0.7, 1.8) {$\binom{V_1\oplus V_2}{V}$};
\node[vertex] (v10) at (0.6,1.2) {$\binom{V_1\oplus V_3}{V}$};
\node[vertex] (v11) at (0.17,1.23) {$\binom{V_2\oplus V_3}{V}$};
\draw[-to] (v1) -- (v2);
\draw[-to] (v1) -- (v3);
\draw[-to] (v1) -- (v4);
\draw[-to] (v2) -- (v8);
%\draw[edge] (v2)--(v6);
\draw[dashed, -to] (v2) -- (v6);
 \draw[-to] (v3) -- (v8);
 \draw[dashed, -to] (v4) -- (v6);
 \draw[-to] (v4) -- (v5);
 \draw[-to] (v8) -- (v7);
 \draw[-to] (v3) -- (v5);
 \draw[-to] (v5) -- (v7);
 \draw[dashed, -to] (v6) -- (v7);
 \draw[-to] (v2) -- (v9);
 \draw[-to] (v3) -- (v9);
 \draw[->] (v9) -- (v8);
 \draw[dashed,->] (v2) -- (v10);
 \draw[dashed,->] (v4) -- (v10);
 \draw[dashed, ->] (v10) -- (v6);
 \draw[->] (v3) -- (v11);
 \draw[->] (v4) -- (v11);
 \draw[->] (v11) -- (v5);

\end{tikzpicture} } \end{figure}

enter image description here

math
  • 179

3 Answers3

1

Here's a way to do it. Without being able to compile your code I assume you face 3 problems:

  • structure/placement of nodes
  • replacement of node content
  • adjustments

1. Placement of nodes

There are several ways to specify the nodes coordinates, like:

  • cartesian coordinates
  • polar coordinates
  • matrix (the Tikz equivalent of a table)
  • etc.

I take the matrix-route here. So all I need to do is to perceive the positions as rows and columns. To better keep track I put node-coordinates in red in this sketch, and rows and columns in blue:

sketch

So Part 1 in the code below just does that:

  • placing such nodes
  • connecting them by two types of styles

Don't worry too much about proportions and sizes, as this can still all be adjusted. Kindly watch the x-shift I used for D3 for that purpose. However, I'd delay that to the last step.

Row \node {\strut}; & & & & & & \\ just functions as a placeholder to give some more vertical space.

placements

2. Replacement of contents (Part 2)

I just show the beginning of this process, replacing some of your content in math-mode.

To better assist the illusion of placing the diagonal nodes, I made the line thickness of the outer ones thicker, see style-statements.

If you don't like the separation of nodes D2 and D3, write them in one row (i.e. delete the excessive one), and perhaps apply some yshift as needed, later.

replacement started

3. Adjustments

So the major adjustment to make will be here for the row and column separations, and perhaps a few shifts you applied where needed:

  \matrix[column sep=6mm, row sep=6mm]

Suggested tactics

  • draw this cube with the standalone class
  • compile it and use \includegraphics for the pdf from the graphicx package in your main document

Code

\documentclass[10pt,border=3mm,tikz]{standalone}
\usetikzlibrary{arrows.meta}
\usepackage{amsmath}

\begin{document} % ~~~ developing the structure ~~~~~~~~~ \begin{tikzpicture}[ vs/.style={->, dashed}, >={Stealth}, ] % ~~~ Part 1: placement ~~~~~~~~~~~~~~~~~~~~~~~~ \matrix[column sep=20mm, row sep=12mm] { \node (100) {100}; & & & & \node (110) {110}; & & \ & & & \node(D1) {D1}; & & \ & & \node (101) {101}; & & & & \node (111) {111}; \ & & \node[xshift=9mm] (D3) {D3}; & & &\ & \node (D2) {D2}; \ \node (000) {000};& & & & \node (010) {010}; & & \ \node {\strut}; & & & & & & \ & & \node (001) {001}; & & & & \node (011) {011}; \ }; % ~~~ connections ~~~~~~~~~ % top \draw[->] (100) -- (110); \draw[->] (100) -- (101); \draw[->] (101) -- (111); \draw[->] (110) -- (111);

% down \draw[->] (100) -- (000); \draw[->] (101) -- (001); \draw[->] (111) -- (011); \draw[vs] (110) -- (010);

% side \draw[->] (000) -- (001); \draw[vs] (010) -- (011); \draw[->] (101) -- (D2); \draw[->] (000) -- (D2); \draw[->] (D2) -- (001);

% bottom \draw[vs] (000) -- (010); \draw[->] (001) -- (011);

% diagonals \draw[->] (101) -- (D1); \draw[->] (110) -- (D1); \draw[->] (D1) -- (111); \draw[vs] (110) -- (D3); \draw[vs] (000) -- (D3); \draw[vs] (D3) -- (010); \end{tikzpicture}

% ~~~ Part 2: replacements ~~~~~~~~~ \begin{tikzpicture}[ vs/.style={->, dashed}, vt/.style={->, line width=1.5pt}, >={Stealth}, ] % ~~~ placement ~~~~~~~~~~~~~~~~~~~~~~~~ \matrix[column sep=6mm, row sep=6mm] { \node (100) {$K(V,0)$}; & & & & \node (110) {$\binom{V_1}{V}$}; & & \ & & & \node(D1) {$\binom{V_1\oplus V_2}{V}$}; & & \ & & \node (101) {$\binom{V_2}{V}$}; & & & & & \node (111) {111}; \ & & \node[xshift=9mm] (D3) {D3}; & & &\ & \node (D2) {D2}; \ \node (000) {000};& & & & \node (010) {010}; & & \ \node {\strut}; & & & & & & \ & & \node (001) {001}; & & & & & \node (011) {011}; \ }; % ~~~ connections ~~~~~~~~~ % top \draw[vt] (100) -- (110); \draw[vt] (100) -- (101); \draw[vt] (101) -- (111); \draw[vt] (110) -- (111);

% down \draw[->] (100) -- (000); \draw[->] (101) -- (001); \draw[->] (111) -- (011); \draw[vs] (110) -- (010);

% side \draw[->] (000) -- (001); \draw[vs] (010) -- (011); \draw[->] (101) -- (D2); \draw[->] (000) -- (D2); \draw[->] (D2) -- (001);

% bottom \draw[vs] (000) -- (010); \draw[->] (001) -- (011);

% diagonals \draw[->] (101) -- (D1); \draw[->] (110) -- (D1); \draw[->] (D1) -- (111); \draw[vs] (110) -- (D3); \draw[vs] (000) -- (D3); \draw[vs] (D3) -- (010); \end{tikzpicture}

\end{document}

MS-SPO
  • 11,519
  • Thank you for the answer. But I want a crossing-over arrow instead of the dashed one. Here is one example of crossing over arrows https://tex.stackexchange.com/questions/353759/how-to-cross-over-only-at-intersections-in-tikzcd – math Nov 22 '23 at 02:39
  • Please see my answer https://tex.stackexchange.com/a/701981/245790, and my suggestion: don't do it with this visual effect ... – MS-SPO Nov 22 '23 at 09:36
1

Follow-up to my answer ; not intended for voting, but to keep a long answer more readable.

Here's one way to do it with plain Tikz. However, I suggest to rethink your crossing-over idea, which is just a visual means, requiring quite some effort with many side effects.

Basic idea

  • once everything else has been drawn
  • draw the cross-over-pathes at the end
  • so their white large outlines cover the rest
  • giving the illusion of "crossing"

This brings some problems with it. Let's see.

result

Style

The new style co uses the double parameters of a path, see Ch. 15 in the pgfmanual.

 % ~~~ Part 3: crossing over  ~~~~~~~~~
 \begin{tikzpicture}[
    vs/.style={->, dashed},
    vt/.style={->, line width=1.5pt},
    >={Stealth},
    % to cross over:
    co/.style={
        % double line parameters:   
        draw=white,double=black,line width=3pt,
        double distance=1.5pt,
        % arrow-tip parameters
        -{Stealth[width=10mm,fill=black]}},
 ]

For better visibility I changed one line to blue on the right side.

As described there it:

  • draws a thick line, including arrows, here in white
  • draws the "normal" line, here in black

There's a trade-off from contradicting requirements:

  • you want a thick white line to "cover/cross" others
  • you want a thin white line to avoid other obscuring artifacts

See the thick front line to 111: the thick white outline of the arrow tip obscures other lines, including the tip. You can balance the co-parameters to some extent ...

Drawing last pathes

Here you see a few approaches combined:

  • first the line to 111 at the top
  • second, a nodes place held being overdrawn
  • third, the blue line at the side with a different approach
  %     crossing over pathes
  %  front, top
  \draw[vt,co] (101) -- (111);
  %  drawing over the placeholder
  \node[fill=white] at (D1) {$\binom{V_1\oplus V_2}{V}$};
  % alternative: draw thick white line AND normal vector
  \draw[draw=white, line width=12pt] (D2) -- (001);
  \draw[->,blue] (D2) -- (001);

The first one I just described.

The second one would "overwrite" the arrows behind (D1) at the top. Two steps:

  • put a big enough empty node into the matrix (code next)
  • put a second node at its place at the end (code before)
%    & & & \node(D1) {$\binom{V_1\oplus V_2}{V}$}; & & \\
%    new: placeholder
     & & & \node[minimum size=10mm] (D1) {}; & & \\

The third just draws a connection twice:

  • once as a big white line without arrow tip
  • and as an ordinary vector
  • kindly recognise the artifacts near 001

Code

\documentclass[10pt,border=3mm,tikz]{standalone}
\usetikzlibrary{arrows.meta}
\usepackage{amsmath}

\begin{document} % ~~~ developing the structure ~~~~~~~~~

% ~~~ Part 3: crossing over ~~~~~~~~~ \begin{tikzpicture}[ vs/.style={->, dashed}, vt/.style={->, line width=1.5pt}, >={Stealth}, % to cross over: co/.style={ % double line parameters:
draw=white,double=black,line width=3pt, double distance=1.5pt, % arrow-tip parameters -{Stealth[width=10mm,fill=black]}}, ] % ~~~ placement ~~~~~~~~~~~~~~~~~~~~~~~~ \matrix[column sep=6mm, row sep=6mm] { \node (100) {$K(V,0)$}; & & & & \node (110) {$\binom{V_1}{V}$}; & & \ % & & & \node(D1) {$\binom{V_1\oplus V_2}{V}$}; & & \ % new: placeholder & & & \node[minimum size=10mm] (D1) {}; & & \ & & \node (101) {$\binom{V_2}{V}$}; & & & & & \node (111) {111}; \ & & \node[xshift=9mm] (D3) {D3}; & & &\ & \node (D2) {D2}; \ \node (000) {000};& & & & \node (010) {010}; & & \ \node {\strut}; & & & & & & \ & & \node (001) {001}; & & & & & \node (011) {011}; \ }; % ~~~ connections ~~~~~~~~~ % top \draw[vt] (100) -- (110); \draw[vt] (100) -- (101);

\draw[vt] (110) -- (111);
% down \draw[->] (100) -- (000); \draw[->] (101) -- (001); \draw[->] (111) -- (011); % highlighting this one: remove the dashed parameter \draw[->,blue] (110) -- (010);% <<< new

% side \draw[->] (000) -- (001); \draw[vs] (010) -- (011); \draw[->] (101) -- (D2); \draw[->] (000) -- (D2); % \draw[->] (D2) -- (001);

% bottom \draw[vs] (000) -- (010); \draw[->] (001) -- (011);

% diagonals \draw[->] (101) -- (D1); \draw[->] (110) -- (D1); \draw[->] (D1) -- (111); \draw[vs] (110) -- (D3); \draw[vs] (000) -- (D3); \draw[vs] (D3) -- (010);

% crossing over pathes % front, top \draw[vt,co] (101) -- (111); % drawing over the placeholder \node[fill=white] at (D1) {$\binom{V_1\oplus V_2}{V}$}; % alternative: draw thick white line AND normal vector \draw[draw=white, line width=12pt] (D2) -- (001); \draw[->,blue] (D2) -- (001);

\end{tikzpicture}

\end{document}

MS-SPO
  • 11,519
  • Thank you so much for this amazing help. One more small issue. Can we resize this diagram? I usually write \begin{figure}[hbt] \centering \scalebox{0.6} { \begin{tikzpicture}[scale=5] – math Nov 23 '23 at 05:09
  • But in this case it is not working. – math Nov 23 '23 at 05:09
0

As follow up to your comment, which is quite unspecific, and this answer being a separate issue.

Background

There are several ways to use Tikz drawings, like:

  • writing code directly into your document (like you seem to do)
  • moving Tikz-code to an external file and \input it (which is basically the same)
  • using package subfiles, which allows separate compilation of each subfile AND the main document
  • my proposal: using package graphicx
  • and certainly more ways to do it

With Tikz code in your main document you probably missed transform shape in your options; see the pgfmanual.

Example

  • first create AND compile your Tikz drawing in a separate file, using class standalone
  • second, include the pdf as graphics

To do so:

  • make the standalone drawing look right
  • i.e. adjust column sep, row sep and node shifts as needed
  • tune for a balanced look first

When including a pdf via graphicx it still remains a vector graphics, i.e. you don't have pixel artifacts, unless your pdf-viewer introduces them.

Result and code

Assuming cubeCross.pdf as standalone file, in teh same directory, from class standalone from my previous answer:

result

\documentclass[10pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{lipsum}

\begin{document} \lipsum[10]

For including the Tikz-drawing see figure \ref{img}.    

\begin{figure}[!h] \includegraphics[width=\textwidth]{cubeCross} \caption{Including cubeCross.pdf}\label{img} \end{figure}

\lipsum[11]

\end{document}

MS-SPO
  • 11,519