Skip to content

Instantly share code, notes, and snippets.

@UweZiegenhagen
Created December 2, 2024 20:23
Show Gist options
  • Select an option

  • Save UweZiegenhagen/cc6a51cfb33211850ef4f3b92b160da6 to your computer and use it in GitHub Desktop.

Select an option

Save UweZiegenhagen/cc6a51cfb33211850ef4f3b92b160da6 to your computer and use it in GitHub Desktop.
tikz cube
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{csquotes}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\def\dim{2cm}
\coordinate (b11) at (1,0);
\coordinate (f11) at (-1,-1);
\coordinate (f11) at ($(b11)+(225:\dim)$);
\coordinate[right = \dim of b11] (b12);
\coordinate[right = \dim of b12] (b13);
\coordinate[below = \dim of b11] (b21);
\coordinate[right = \dim of b21] (b22);
\coordinate[right = \dim of b22] (b23);
\coordinate[below = \dim of b21] (b31);
\coordinate[right = \dim of b31] (b32);
\coordinate[right = \dim of b32] (b33);
\draw (b11) -- (b13);
\draw (b13) -- (b33);
\draw[dashed] (b11) -- (b31);
\draw[dashed] (b31) -- (b33);
\draw[dashed] (b21) -- (b23);
\draw[dashed] (b32) -- (b12);
\coordinate (m11) at ($(f11)!0.5!(b11)$);
\coordinate[right = \dim of m11] (m12);
\coordinate[right = \dim of m12] (m13);
\coordinate[below = \dim of m11] (m21);
\coordinate[right = \dim of m21] (m22);
\coordinate[right = \dim of m22] (m23);
\coordinate[below = \dim of m21] (m31);
\coordinate[right = \dim of m31] (m32);
\coordinate[right = \dim of m32] (m33);
\draw (m11) -- (m13);
\draw (m13) -- (m33);
\draw[dashed] (m11) -- (m31);
\draw[dashed] (m31) -- (m33);
\draw[dashed] (m21) -- (m23);
\draw[dashed] (m32) -- (m12);
\coordinate[right = \dim of f11] (f12);
\coordinate[right = \dim of f12] (f13);
\coordinate[below = \dim of f11] (f21);
\coordinate[right = \dim of f21] (f22);
\coordinate[right = \dim of f22] (f23);
\coordinate[below = \dim of f21] (f31);
\coordinate[right = \dim of f31] (f32);
\coordinate[right = \dim of f32] (f33);
\draw[dashed] (f32) -- (f12);
\draw [dashed] (f31) -- (b31);
\draw [dashed] (f21) -- (b21);
\draw [dashed] (f32) -- (b32);
\draw (f12) -- (b12);
\draw (f23) -- (b23);
\draw (f23) -- (b23);
\draw (b11) -- (f11);
\draw (b13) -- (f13);
\draw (b33) -- (f33);
\draw(f21) -- (f23);
\draw(f12) -- (f32);
\draw (f11) -- (f13);
\draw (f13) -- (f33);
\draw (f11) -- (f31);
\draw (f31) -- (f33);
\end{tikzpicture}
\end{document}
@UweZiegenhagen
Copy link
Author

public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment