52

I'm wondering whether is possible to draw a Moebius Strip using TikZ. The closest thing I've seen is in Texamples' page, but no luck so far!

Do you have any ideas? I don't even have a MWE (sorry)

1
  • I suggest you to use inkscape to draw it.
    – Sigur
    Commented Jun 10, 2013 at 23:25

5 Answers 5

72

With PGFPlots:

\documentclass{standalone}


\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    hide axis,
    view={40}{40}
]
\addplot3 [
    surf, shader=faceted interp,
    point meta=x,
    colormap/greenyellow,
    samples=40,
    samples y=5,
    z buffer=sort,
    domain=0:360,
    y domain=-0.5:0.5
] (
    {(1+0.5*y*cos(x/2)))*cos(x)},
    {(1+0.5*y*cos(x/2)))*sin(x)},
    {0.5*y*sin(x/2)});

\addplot3 [
    samples=50,
    domain=-145:180, % The domain needs to be adjusted manually, depending on the camera angle, unfortunately
    samples y=0,
    thick
] (
    {cos(x)},
    {sin(x)},
    {0});
\end{axis}
\end{tikzpicture}

\end{document}
10
  • Thank you for the marvellous answer! Is it possible to superpose the Moebius strip with the middle circle?, I'd like to highlight that the Moebius strip is based on a circle! :-P Thank you very much.
    – Dox
    Commented Jun 11, 2013 at 13:20
  • @Dox: Yes, you can add a second plot for that. Unfortunately, PGFPlots can't do the z buffering for separate plots, so you'll have to set the domain for the circle manually to make sure the hidden parts aren't drawn.
    – Jake
    Commented Jun 11, 2013 at 13:47
  • Magnificent! I tried, but got a much less nice than your. Cheers.
    – Dox
    Commented Jun 11, 2013 at 14:00
  • @Jake: Why I get a triangular mesh instead of a rectangular mesh as you when I run this code (with pdflatex)? It's all about pgfplots package update or another trick?
    – rafaeldf
    Commented Jun 13, 2013 at 16:30
  • 2
    There are two extra closing braces: ))) in line 23 and 24. I do not know why it works with extra closing braces. Commented Feb 7 at 18:27
43

As a quotient space:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[
decoration={
  markings,
  mark=at position 0.5 with {\arrow{>}}}
] 
\draw[postaction=decorate] (0,0) -- (2,0);
\draw (2,0) -- (2,-2);
\draw[postaction=decorate] (2,-2) -- (0,-2);
\draw (0,0) -- (0,-2);
\end{tikzpicture}

\end{document}

enter image description here

And now, taken from MoebiusStrip.tex:

% Title: Moebius Strip
% Tags: Clipping, Node positioning, Shadings, Macros
% Authors: Jacques Duma & Gerard Tisseau
% Site: http://math.et.info.free.fr/TikZ/index.html

\documentclass{article}

\usepackage{tikz}
\usepackage{verbatim}

\begin{comment}
:Title: Moebius Strip
:Tags: Clipping, Node positioning, Shadings, Macros
:Authors: Jacques Duma & Gerard Tisseau
:Site: http://math.et.info.free.fr/TikZ/index.html

To build this Moebius Strip, take a normal strip of paper, write "TikZ for LaTeX" on one side, give it 3 half-twists and join the ends.

The resulting strip has only one face and one boundary.
\end{comment}

% one third of the Moebius Strip
%: \strip{<angle>}
\newcommand{\strip}[1]{%
\shadedraw[very thick,top color=white,bottom color=gray,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}

\pagestyle{empty}

\begin{center}
\begin{tikzpicture} [rotate=22]
  \MoebiusStrip{Ti{\color{orange}\textit{k}}Z}{for}{\LaTeX}
\end{tikzpicture}
\end{center}

\end{document}

enter image description here

0
40

enter image description here

As a parametric surface with the Asymptote:

\documentclass{article}
\usepackage[inline]{asymptote}
\begin{document}
\begin{figure}
\centering
\begin{asy}
import graph3;
size(200,IgnoreAspect);
size3(200,IgnoreAspect);
currentprojection=orthographic(camera=(1.5,0.3,2),up=Z,target=(0.5,0,0),zoom=0.8);
real r=2, w=1;
real x(real u, real v){return (r+v/2*cos(3pi*u))*cos(2pi*u);};
real y(real u, real v){return (r+v/2*cos(3pi*u))*sin(2pi*u);};
real z(real u, real v){return (v/2*sin(3pi*u));};
triple f(pair p){return (x(p.x,p.y),y(p.x,p.y),z(p.x,p.y));};
draw(surface(f,(0,-w),(1,w),nu=9,Spline),orange);
\end{asy}
\caption{M\"obius strip.}
\end{figure}
\end{document}
21

With PSTricks. Stolen from Herbert's answer.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-3dplot}

\begin{document}
\psset{Beta=20}
\begin{pspicture}(-6,-3)(6,4)
\def\Radius{5 }
\parametricplotThreeD[xPlotpoints=100,yPlotpoints=10](0,360)(-1,1){
   t 2 div cos u mul \Radius add t cos mul
   t 2 div cos u mul \Radius add t sin mul
   t 2 div sin u mul }
\pstThreeDCoor[xMin=-1,yMin=-1,zMin=-1]
\parametricplotThreeD[xPlotpoints=100,yPlotpoints=1,
    linecolor=red,linewidth=2pt,arrows=|->](180,-180){
   t 2 div cos \Radius add t cos mul
   t 2 div cos \Radius add t sin mul
   t 2 div sin }
\end{pspicture}

\end{document}

enter image description here

1
  • Gorgeous. But what does mean "mul" ? I get this error message : Undefined control sequence. \c@lor@to@ps ->\PSTricks _Not_Configured_For_This_Format l.11 t 2 div sin u mul } The control sequence at the end of the top line of your error message was never \def'ed. Commented Sep 3, 2023 at 9:09
7

Another PsTricks solution, using pst-solide3d, adapted from a code from Manuel Luque:

    \listfiles
    \documentclass[pdf,dvipsnames,svgnames, x11names]{standalone}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{lmodern}
    \usepackage{pst-solides3d}
    \begin{document}
    \pagestyle{empty}

    \begin{pspicture}(-4.2,-1.7)(5.1,3)
    \psset{unit=1.5}
    \psframe*[linecolor=DarkSeaGreen4!80](-4.2,-1.7)(5.1,3)
    \psset[pst-solides3d]{viewpoint=20 10 5, Decran=40, lightsrc=20 10 10}
    \psPoint(3.5,0,0){X}
    \psPoint(0,2.8,0){Y}
    \psPoint(0,0,1.5){Z}
    \psPoint(0,0,0){O}\uput[d](O){$ O $}
    \psline{->}(O)(X)\uput[-160](X){$x$}
    \defFunction{mobius}(u,v)
       {2 u v Cos mul add 2 v mul Cos mul}
       {2 u v Cos mul add 2 v mul Sin mul}
       {u v Sin mul}
    \psSolid[object=surfaceparametree,linewidth=0.75\pslinewidth,
       base=0.2 0.25 0 pi,linewidth=0.1,
       function=mobius,
       ngrid=.025]%
    \psSolid[object=surfaceparametree,linewidth=0.75\pslinewidth,
       base=-0.25 -0.2 0 pi,linewidth=0.1,
       function=mobius,
       ngrid=.025]%
    \psSolid[object=surfaceparametree,linewidth=0.5\pslinewidth,
       base=-0.25 0.25 0 pi,fillcolor=yellow!50,incolor=yellow!50,
       function=mobius,
       ngrid=.05]%
    \psline{->}(O)(Y)\uput[-15](Y){$y$}
    \psline{->}(O)(Z)\uput[u](Z){$z$}
    \end{pspicture}

    \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 .