2

Using Moebius Strip using TikZ I can draw a perfect Moebius strip.

moeb3

How can I add a layer of boxes and corresponding lines to achieve the following?

Moebius2

EDIT: I managed to put a box inside and draw a line, but moving the box moves the moebius strip as well. How can I move the boxes to a different layer?

\documentclass{beamer}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}

\usepackage{xcolor}
\definecolor{chamois}{RGB}{255,255,240}
\definecolor{darkbrown}{RGB}{124,79,0}

\newcommand{\strip}[1]{%
\shadedraw[very thick,top color=chamois,bottom color=darkbrown,rotate=#1]
 (0:2.8453) ++ (-30:1.5359) arc (60:0:2)
 -- ++  (90:5) arc (0:60:2) -- ++ (150:3) arc (60:120:2) 
 -- ++ (210:5) arc (120:60:2) -- cycle;}

%: \MoebiusStrip{<text1>}{<text2>}{<text3>}
\newcommand{\MoebiusStrip}[3]{%
\begin{scope} [transform shape]
    \strip{0}
    \strip{120}
    \strip{-120}
    \draw (-60:3.5) node[scale=6,rotate=30] {#1};
    \draw (180:3.5) node[scale=4,rotate=-90]{#3};
    % redraw the first strip after clipping
    \clip (-1.4,2.4)--(-.3,6.1)--(1.3,6.1)--(5.3,3.7)--(5.3,-2.7)--cycle;
    \strip{0}
    \draw (60:3.5) node [gray,xscale=-4,yscale=4,rotate=30]{#2};
\end{scope}}

\begin{document}

\frame{

\begin{center}
\begin{tikzpicture} [scale=0.75, every node/.style={transform shape},
    mybox/.style={rectangle,rounded corners,xshift=1cm,yshift=1cm,minimum width=35mm, minimum height=22.5mm},
    topline/.style={mybox,red,align=center,draw=red,very thick,font=\bfseries},
]
  \MoebiusStrip{~}{~}{~};
  \node (a) at (-9,4) [topline] {X};
  \node (center) at (0,0){};

\draw(a.south east) -- (center.west);
\end{tikzpicture}
\end{center}
}

\end{document}
Uwe Ziegenhagen
  • 13,168
  • 5
  • 53
  • 93
  • What is your problem? Finding the points on the Möbius strip or placing the boxes and connecting them to well-defined points on the strip? – Qrrbrbirlbel Jul 07 '13 at 09:20
  • Placing the boxes is the issue. The points on the strip are not that important as I can place them manually. What would be nice: getting a grid for the boxes, getting an anchor for each box (like "north-west" or "south") and a x-y parameter for the other end of the line. – Uwe Ziegenhagen Jul 07 '13 at 09:55
  • Well, then that’s easy. You can use the positioning library and place the nodes with it in relation, where the node distance is the space between the nodes. With the positioning library, you can also use the on grid option which measures the node distance between the center anchors of the nodes. Then you have the \matrix (and its library) where you can place nodes in a matrix, very much grid-like. With the name of the node and a suitable anchor, you can let the lines end very specifically. The coordinates on the strip are very easy to specify manual. – Qrrbrbirlbel Jul 07 '13 at 10:53
  • I updated my question, positioning the nodes works, but I have an issue with the layers. Moving the box moves the moebius strip. therweis it looks good. I need to finish the graphics today, so I guess I'll do the positioning manually to save some time. – Uwe Ziegenhagen Jul 07 '13 at 11:28
  • The whole TikZ picture moves. As the node changes its width but only to one side, thus making the center of the picture not the center of the strip. If you place nodes symmetrically the strip will place in the center of the slide. – Qrrbrbirlbel Jul 07 '13 at 11:34

2 Answers2

4

I think the \matrix is the easiest way to ensure a grid-like placement. Sure, the positioning library and the on grid option would help to, but then the initial placement would be kind of tricky. The center of the Möbius strip lies at the coordinate (0,0) which is also the default location of the center of the matrix (which is a rectangle-like node).

The TikZ picture wide rotate option has been moved to the \MoebiusStrip macro so that the only transformation does not affect anything else. The nodes in the matrix are getting auto-named with (<matrix name>-<row>-<column>) which can be used to reference the node later.

In the \foreach loop I assign each row/column combination an anchor as well as a counter via the count option (which is only used for purposes that probably won’t affect your use-case. You may add another variable for the coordinate that will be connected.

Code

\documentclass{beamer}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{xcolor}
\definecolor{chamois}{RGB}{255,255,240}
\definecolor{darkbrown}{RGB}{124,79,0}

\newcommand{\strip}[1]{%
\shadedraw[very thick,top color=chamois,bottom color=darkbrown,rotate=#1]
 (0:2.8453) ++ (-30:1.5359) arc (60:0:2)
 -- ++  (90:5) arc (0:60:2) -- ++ (150:3) arc (60:120:2) 
 -- ++ (210:5) arc (120:60:2) -- cycle;}

%: \MoebiusStrip{<text1>}{<text2>}{<text3>}
\newcommand{\MoebiusStrip}[4][]{%
\begin{scope}[transform shape,#1]
    \strip{0}
    \strip{120}
    \strip{-120}
    \draw (-60:3.5) node[scale=6,rotate=30] {#2};
    \draw (180:3.5) node[scale=4,rotate=-90]{#4};
    % redraw the first strip after clipping
    \clip (-1.4,2.4)--(-.3,6.1)--(1.3,6.1)--(5.3,3.7)--(5.3,-2.7)--cycle;
    \strip{0}
    \draw (60:3.5) node [gray,xscale=-4,yscale=4,rotate=30]{#3};
\end{scope}}

\begin{document}

\begin{frame}
\begin{center}
\begin{tikzpicture}[scale=0.4]
  \MoebiusStrip[rotate=30]{~}{~}{~}
  \matrix [
    matrix of nodes,
    ampersand replacement=\&,
    column sep=.25cm,
    row sep=.25cm,
    nodes={
      draw,
      minimum width=1.75cm,
      minimum height=1.5cm
    }
    ] (m) {
    A \& B \& C \& D \& E \\
    F \&   \&   \&   \& G \\
    H \&   \&   \&   \& I \\
    J \&   \&   \&   \& K \\
    L \& M \& N \& O \& P \\  
  };
  \foreach \Node/\Anchor [count=\Angle from 0, evaluate={\AngleC=\Angle/15*100}] in {%
                                    3-5/west,
                                    2-5/west,
                                    1-5/south west,
                                    1-4/south,
                                    1-3/south,
                                    1-2/south,
                                    1-1/south east,
                                    2-1/east,
                                    3-1/east,
                                    4-1/east,
                                    5-1/north east,
                                    5-2/north,
                                    5-3/north,
                                    5-4/north,
                                    5-5/north west,
                                    4-5/west} \path (m-\Node.\Anchor) edge[color=red!\AngleC!blue] (\Angle/16*360:4);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

Output

enter image description here

Moriambar
  • 11,466
Qrrbrbirlbel
  • 119,821
2

This answer is related to the question, but because the questioner wants lines connecting the boxes to the figure parts, it is not an ideal answer. Nonetheless, it may help others who have a similar problem, without requiring a tikz solution. (Obviously, creating the picture with more border would aid the layout, which I had no control over the original image).

\documentclass{article}
\usepackage{stackengine}
\usepackage{graphicx}
\def\stackalignment{l}
\newcommand\insetbox[1]{%
  \fbox{\parbox[t]{1in}{#1\\}}%
}
\begin{document}
\def\stackalignment{l}
{\bottominset{\insetbox{7}}%
{\topinset{\insetbox{5}}%
{\def\stackalignment{r}%
\topinset{\insetbox{6}}%
{\bottominset{\insetbox{8}}%
{\bottominset{\insetbox{11}}%
{\bottominset{\insetbox{12}}%
{\def\stackalignment{l}\bottominset{\insetbox{10}}%
{\bottominset{\insetbox{9}}%
{\def\stackalignment{r}\topinset{\insetbox{3}}%
{\topinset{\insetbox{4}}%
{\def\stackalignment{l}\topinset{\insetbox{2}}%
{\topinset{\insetbox{1}}%
  {\includegraphics{hlCr3}}{1.4\baselineskip}{0pt}}%
{1.4\baselineskip}{90pt}}%
{1.4\baselineskip}{0pt}}%
{1.4\baselineskip}{90pt}}%
{1.4\baselineskip}{0pt}}%
{1.4\baselineskip}{90pt}}%
{1.4\baselineskip}{0pt}}%
{1.4\baselineskip}{90pt}}%
{7\baselineskip}{0pt}}%
{7\baselineskip}{0pt}}%
{7\baselineskip}{0pt}}%
{7\baselineskip}{0pt}}%

\end{document}

enter image description here