10

Almost surely you don't know who Micah McCurdy is, but here is a sample of his diagrams, on pages 20-21, for example, or page 27 for something fancier. I asked him how he did them, and unfortunately it is not a 'native' (La)TeX method, involving two separate software packages.

I'd like to be able to do this in TikZ or PSTricks, but I know nothing about either of these. This project would be my opportunity to learn. I'd like to do something modular, to aid coding up of diagrams as a method of computation, rather than just drawing them all(on paper, say) by hand and then laboriously programming them.

arXiv:1110.5542v1, page 20

EDIT: Thanks to Tom Bombadil for having a go at the example pasted in by canaaerus, which was a good example of the visual complexity possible, but I do need the graphical elements specified on pages 7 and 8 of the above linked pdf, in conjunction with things from page 3. (This is just so that there is a complete record of what I am after.)

enter image description here

5
  • 1
    Looks fairly similar to a braid so I'd start by looking at the braids package and working from there to add the shapes and the double-backs. You might be able to persuade the author to add the ability for the double-backs to the braids package. Commented Aug 27, 2012 at 8:42
  • (See also tex.stackexchange.com/q/16897/86 for where the braids package came from.) Commented Aug 27, 2012 at 8:42
  • @AndrewStacey - do you know what sort of persuasion the said author is amenable to? I guess the starting point is to get my hands dirty and then cry for help when things seize up/break beyond my capabilities to fix. To make things easier I don't need some of the features in the above, like the 'bridges' i.e. I only have planar diagrams, but they will be more involved. When it comes down to nuts and bolts I can supply examples. Commented Aug 27, 2012 at 8:48
  • 2
    Now that you have Tom Bombadill's answer, and the hint about the braids package, I think the "cry for help when things seize up" is your best strategy. I think the author of the braids package is pretty amenable to just being asked (but be aware that he can get a bit snowed under at times!). Commented Aug 27, 2012 at 8:53
  • Regarding your edit: this is definitely the point at which you have a go and cry for help when things seize up. Making complicated diagrams is partly complicated simply due to the number of different ways there are to achieve the same ends. I would start by drawing those modules in as generic way as you can and then asking about how to do specific pieces that you find yourself unable to do. Break the problem down into pieces and try those, building up to a full solution, and ask as and when you need to. Commented Aug 27, 2012 at 10:36

1 Answer 1

17

Here's a concept, it uses zeroth's answer in Triple lines in TikZ.

The Code

\documentclass{article}
\usepackage{tikz}

\begin{document}

\tikzset{
    triple/.style args={[#1] in [#2] in [#3]}{#1,preaction={preaction={draw,#3},draw,#2}},
    McCurdy/.style={triple={[line width=0.5pt,black] in [line width=2mm,red!30] in [line width=2mm+1pt,black]}},
}

\newcommand{\trapezium}[1]% shift as x,y (lower left corner)
{ \draw[fill=white,shift={(#1)}](0,0) -- (0.3,0) -- (0.3,0.8) -- (0,0.95) -- cycle;
}        

\begin{tikzpicture}
  \draw[McCurdy,rounded corners=1mm] (0,0) coordinate (start1) -- (5,0) -- (5,1) -- (2,1) -- (2,2) -- (2.5,2) -- (2.7,2.2) coordinate (end1);
  \draw[McCurdy,rounded corners=1mm] (2.9,2.4) coordinate (start2) -- (3.5,3) -- (7,3) coordinate (end2);
  \node[left] at (start1) {x};
  \trapezium{4,0.8}
  \trapezium{6,2.8}
  \pgfmathsetmacro{\xydim}{sqrt(2)/2*(1mm+0.5pt)/28.4528}
  \draw (end1) ++ (-\xydim,\xydim) -- ++ (2*\xydim,-2*\xydim);
  \draw (start2) ++ (-\xydim,\xydim) -- ++ (2*\xydim,-2*\xydim);
  \draw[rounded corners=1mm] (2.8,2.3) -- (2,3.1) -- (0.8,3.1)
    (2.8,2.3) -- (3.6,1.5) -- (4,1.5);
\end{tikzpicture}
\end{document}

The Output

enter image description here


Edit 1: A concept for drawing "holes", but only up-down on parallel left to right lines. It draws over the existing lines:

enter image description here

The Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\pgfmathsetmacro{\rlw}{0.2}
\pgfmathsetmacro{\blw}{0.02}

\pgfmathsetmacro{\hbw}{\blw/2}
\pgfmathsetmacro{\qbw}{\blw/4}
\pgfmathsetmacro{\hrw}{\rlw/2}

\tikzset{
    triple/.style args={[#1] in [#2] in [#3]}{#1,preaction={preaction={draw,#3},draw,#2}},
    McCurdy/.style={triple={[line width=\blw cm,black] in [line width=\rlw cm,red!30] in [line width=2*\blw cm+\rlw cm,black]}},
}

\newcommand{\trapezium}[1]% shift as x,y (lower left corner)
{ \draw[fill=white,shift={(#1)}](0,0) -- (0.3,0) -- (0.3,0.8) -- (0,0.95) -- cycle;
} 

\def\connector(#1,#2,#3)% midposition one, midposition two, radius
{   \path (#1);
    \pgfgetlastxy{\xtl}{\ytl}
    \path (#2);
    \pgfgetlastxy{\xbr}{\ybr}
    \pgfmathsetmacro{\xmin}{min(\xtl,\xbr)/28.453}
    \pgfmathsetmacro{\xmax}{max(\xtl,\xbr)/28.453}
    \pgfmathsetmacro{\ymin}{min(\ytl,\ybr)/28.453}
    \pgfmathsetmacro{\ymax}{max(\ytl,\ybr)/28.453}
    \fill[red!30] ($(\xmin,\ymax)+(-#3,-\hrw)$)
        arc (90:0:#3) -- 
        ($(\xmin,\ymin)+(0,#3+\hrw)$)
        arc (360:270:#3) --
        ($(\xmax,\ymin)+(#3,\hrw)$)
        arc (270:180:#3) --
        ($(\xmax,\ymax)+(0,-#3-\hrw)$)
        arc (180:90:#3) --
        cycle ;
    \draw[line width=\blw cm] ($(\xmin,\ymax)+(-#3,-\hrw)+(0,-\hbw)$)
        arc (90:0:#3) -- 
        ($(\xmin,\ymin)+(0,#3+\hrw+\hbw)$)
        arc (360:270:#3);
    \draw[line width=\blw cm] ($(\xmax,\ymax)+(#3,-\hrw)+(0,-\hbw)$)
        arc (90:180:#3) -- 
        ($(\xmax,\ymin)+(0,#3+\hrw+\hbw)$)
        arc (180:270:#3);   
}       

\begin{tikzpicture}
  \draw[McCurdy,rounded corners=1mm] (0,0) -- (1,0) coordinate (a) -- (3,0) coordinate (b) -- (4,0);
  \draw[McCurdy,rounded corners=1mm] (0,-1) -- (1.2,-1) coordinate (c) -- (2.7,-1) coordinate (d) -- (4,-1);
  \draw[McCurdy,rounded corners=1mm] (0,-2) -- (1.6,-2) coordinate (e) -- (2.0,-2) coordinate (f) -- (4,-2);
    \connector(a,c,0.15)
  \connector(b,d,0.2)
  \connector(c,e,0.05)
  \connector(d,f,0.1)
 \end{tikzpicture} 

\end{document}

The Output

enter image description here

1
  • Excellent! Thank you for the additional code. Commented Aug 27, 2012 at 23:28

You must log in to answer this question.

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