Drawing ramified coverings with tikz












11















I want to draw a diagram similar to this one:





For that I started with the following code:



begin{tikzpicture}
draw (0,0) node {$Y$};
draw (0,2) node {$X$};
draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};
draw[thick] (1,0) -- (7,0);
draw[thick] (1,2) -- (7,2);
draw[thick] (1,2.5) -- (7,2.5);
draw[thick] (1,1.5) -- (7,1.5);
end{tikzpicture}


The only thing that I don't know how to do is the curvy parts. I would appreciate some indication.










share|improve this question

























  • Although it doesn't have curvy links, tikz-timing could be useful to draw this kind of diagrams.

    – Ignasi
    17 hours ago
















11















I want to draw a diagram similar to this one:





For that I started with the following code:



begin{tikzpicture}
draw (0,0) node {$Y$};
draw (0,2) node {$X$};
draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};
draw[thick] (1,0) -- (7,0);
draw[thick] (1,2) -- (7,2);
draw[thick] (1,2.5) -- (7,2.5);
draw[thick] (1,1.5) -- (7,1.5);
end{tikzpicture}


The only thing that I don't know how to do is the curvy parts. I would appreciate some indication.










share|improve this question

























  • Although it doesn't have curvy links, tikz-timing could be useful to draw this kind of diagrams.

    – Ignasi
    17 hours ago














11












11








11


1






I want to draw a diagram similar to this one:





For that I started with the following code:



begin{tikzpicture}
draw (0,0) node {$Y$};
draw (0,2) node {$X$};
draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};
draw[thick] (1,0) -- (7,0);
draw[thick] (1,2) -- (7,2);
draw[thick] (1,2.5) -- (7,2.5);
draw[thick] (1,1.5) -- (7,1.5);
end{tikzpicture}


The only thing that I don't know how to do is the curvy parts. I would appreciate some indication.










share|improve this question
















I want to draw a diagram similar to this one:





For that I started with the following code:



begin{tikzpicture}
draw (0,0) node {$Y$};
draw (0,2) node {$X$};
draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};
draw[thick] (1,0) -- (7,0);
draw[thick] (1,2) -- (7,2);
draw[thick] (1,2.5) -- (7,2.5);
draw[thick] (1,1.5) -- (7,1.5);
end{tikzpicture}


The only thing that I don't know how to do is the curvy parts. I would appreciate some indication.







tikz-pgf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Cragfelt

2,96531028




2,96531028










asked 2 days ago









Gabriel RibeiroGabriel Ribeiro

35519




35519













  • Although it doesn't have curvy links, tikz-timing could be useful to draw this kind of diagrams.

    – Ignasi
    17 hours ago



















  • Although it doesn't have curvy links, tikz-timing could be useful to draw this kind of diagrams.

    – Ignasi
    17 hours ago

















Although it doesn't have curvy links, tikz-timing could be useful to draw this kind of diagrams.

– Ignasi
17 hours ago





Although it doesn't have curvy links, tikz-timing could be useful to draw this kind of diagrams.

– Ignasi
17 hours ago










7 Answers
7






active

oldest

votes


















13














This uses the same in and out trick as Skillmon and puts it into a style dip, which takes as arguments the horizontal position and the depth, where the sign decides whether the dip is a dip (minus) or a bump (plus). (Let me also mention that you do not need to do something like draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};. If you name the nodes, you can just do draw[<-] (Y) -- (X) node[left, midway] {$f$}; and TikZ will make sure to shorten the arrow without you having to compute the coordinates.)



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{positioning}
newcounter{dip}
begin{document}
begin{tikzpicture}[dip/.style args={#1/#2}{/utils/exec=stepcounter{dip},
insert path={%
coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3)
(aux1) -- (aux2|-aux1) to[out=0,in=180]
++({abs(#2)},#2) coordinate(dip-thevalue{dip}) to[out=0,in=180] (aux3|-aux1)
}}]
begin{scope}[thick,local bounding box=dips]
draw (1,2.5) [dip=5.5cm/-2.5mm]-- (7,2.5);
fill (dip-1) circle[radius=2pt] node[right=3pt]{$b=1$};
draw (1,2) [dip/.list={2.5cm/-2.5mm,5.5cm/2.5mm}] -- (7,2);
fill (dip-2) circle[radius=2pt] node[right=3pt]{$b=1$};
draw (1,1.5) [dip/.list={2.5cm/2.5mm,5.5cm/-5mm}] -- (7,1.5);
fill (dip-5) circle[radius=2pt] node[above right=0pt and 5pt]{$b=2$};
draw (1,1) -- (7,1);
draw (1,0.5) [dip=5.5cm/5mm] -- (7,0.5);
end{scope}
node[left=2pt of dips.west] (X) {$X$};
draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
draw[<-] (Y) -- (X) node[left, midway] {$f$};
foreach X in {1,2}
{
fill (dip-X|-Y) circle[radius=2pt];
draw[dashed] (dip-X|-Y) -- (dip-X|-0,2.75);
}
end{tikzpicture}
end{document}


enter image description here



Just for fun: a variation for Skillmon.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{positioning}
newcounter{dip}
begin{document}
begin{tikzpicture}[dip/.style={/utils/exec=stepcounter{dip},
insert path={%
to[out=0,in=180]
++(0.25,#1) node[bullet](dip-thevalue{dip}){}
to[out=0,in=180] ++(0.25,-1*#1)
}},bullet/.style={circle,fill,inner sep=1.5pt}]
begin{scope}[thick,local bounding box=dips]
draw (1,2.5) -- (5.25,2.5) [dip=-2.5mm]-- (7,2.5);
node[right=3pt of dip-1]{$b=1$};
draw (1,2) -- (2.25,2) [dip=-2.5mm] -- (5.25,2) [dip=2.5mm] --(7,2);
node[right=3pt of dip-2]{$b=1$};
draw (1,1.5) -- (2.25,1.5) [dip=2.5mm] --(5.25,1.5) [dip=-5mm] -- (7,1.5);
node[above right=-1.5pt and 5pt of dip-5]{$b=2$};
draw (1,1) -- (7,1);
draw (1,0.5) --(5.25,0.5) [dip=5mm] -- (7,0.5);
end{scope}
node[left=2pt of dips.west] (X) {$X$};
draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
draw[<-] (Y) -- (X) node[left, midway] {$f$};
foreach X in {1,2}
{
draw[dashed] (dip-X|-Y) node[bullet]{} -- (dip-X|-0,2.75);
}
end{tikzpicture}
end{document}


enter image description here






share|improve this answer


























  • Very nice automation. Just out of curiosity (coding TikZ is still something I'm not good at), is it possible to also draw the filled circles inside the dip style?

    – Skillmon
    yesterday






  • 1





    @Skillmon Yes, of course. E.g. dip/.style args={#1/#2}{/utils/exec=stepcounter{dip}, insert path={% coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3) (aux1) -- (aux2|-aux1) to[out=0,in=180] ++({abs(#2)},#2) node[circle,fill,inner sep=1.5pt](dip-thevalue{dip}){} to[out=0,in=180] (aux3|-aux1) }}.

    – marmot
    yesterday



















11














The following is a pretty manual way to do this. I only did it for the first two lines, I hope you can apply it to the other occurrences. It uses the in and out keys of the to path construction:



documentclass[tikz]{standalone}

begin{document}
begin{tikzpicture}
draw (0,0) node {$Y$};
draw (0,2) node {$X$};
draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};
draw[thick] (1,2.5) -- (7,2.5) coordinate(a);
draw[thick] (1,2) -- (7,2) coordinate(b);
draw[thick] (1,1.5) -- (7,1.5) coordinate(c);
draw[thick] (1,0) -- (7,0) coordinate(d);
draw[thick]
(a) ++(.25,-.25) coordinate(ab) to[out=180,in=0] (a)
(ab) to[out=180,in=0] (b)
(ab) to[out=0,in=180] ++(.25,.25)
(ab) to[out=0,in=180] ++(.25,-.25)
;
filldraw
(ab) circle(.05)
;
end{tikzpicture}
end{document}


enter image description here






share|improve this answer

































    10














    This is a proof of concept how to use parser library to define the following "language" :





    • = stay at the same level


    • u goes half up


    • U goes one up


    • d goes half down


    • D goes one down


    • x plot a (red) dot


    • . end


    Here is the code.



    documentclass[tikz,border=7pt]{standalone}
    usepgfmodule{parser}
    % -----------------------------
    % macro that add #1 to the current path when used inside pgfextra
    definsertpath#1{tikzset{insert path={#1}}}
    % define the parser "sheet path"
    pgfparserdef{sheet path}{initial}{the character =}{insertpath{ -- ++(1, 0)}}
    pgfparserdef{sheet path}{initial}{the letter u}{insertpath{ to[out=0,in=180] ++(1, .5)}}
    pgfparserdef{sheet path}{initial}{the letter U}{insertpath{ to[out=0,in=180] ++(1, 1)}}
    pgfparserdef{sheet path}{initial}{the letter d}{insertpath{ to[out=0,in=180] ++(1,-.5)}}
    pgfparserdef{sheet path}{initial}{the letter D}{insertpath{ to[out=0,in=180] ++(1, -1)}}
    pgfparserdef{sheet path}{initial}{the letter x}{insertpath{ node[red,scale=4]{.}}}
    pgfparserdef{sheet path}{initial}{the character .}{pgfparserswitch{final}}
    % the sheet interface macro
    defsheet#1.{pgfextra{pgfparserparse{sheet path}#1.}}
    % -----------------------------
    begin{document}
    tikzdraw[thick]
    (0,-1) sheet======du=.
    (0,-2) sheet==du==uxd=.
    (0,-3) sheet==uxd==DU=.
    (0,-4) sheet=========.
    (0,-5) sheet======UxD=.;
    end{document}


    enter image description here






    share|improve this answer



















    • 3





      +1, I didn't know parser, wow!

      – CarLaTeX
      yesterday



















    9














    I think Bézier curves can do the task. It can make sure that the starting points and the ending points of all curves are placed with a consistent ratio.



    documentclass[tikz]{standalone}
    definnersep{.5em}
    usetikzlibrary{patterns}
    begin{document}
    begin{tikzpicture}[y=baselineskip+2*innersep]
    draw (0,0)--(6.5,0);
    draw (0,1.5)--(6.5,1.5);
    draw (0,1)--(4.75,1) .. controls (4.9,1) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,1) .. (5.25,1)--(6.5,1);
    draw (0,2)--(1.25,2) .. controls (1.4,2) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2) .. (1.75,2)--(4.75,2) .. controls (4.9,2) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,2) .. (5.25,2)--(6.5,2);
    draw (0,2.5)--(1.25,2.5) .. controls (1.4,2.5) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2.5) .. (1.75,2.5)--(4.75,2.5) .. controls (4.9,2.5) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,2.5) .. (5.25,2.5)--(6.5,2.5);
    draw (0,3)--(4.75,3) .. controls (4.9,3) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,3) .. (5.25,3)--(6.5,3);
    fill (1.5,2.25) circle (1.5pt) (5,1.5) circle (1.5pt) (5,2.75) circle (1.5pt) (1.5,0) circle (1.5pt) (5,0) circle (1.5pt);
    draw[dashed] (1.5,0)--(1.5,3.25) (5,0)--(5,3.25);
    draw (1.5,2.25) node[right=1ex] {$b=1$};
    draw (5,1.75) node[right=1ex] {$b=2$};
    draw (5,2.75) node[right=1ex] {$b=1$};
    draw (-0.5,0) node (n) {$N$};
    draw (-0.5,2.25) node (m) {$M$};
    draw[-latex] (m)--(n) node[midway,left] {$f$};
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer































      6














      This is a proof of concept how to use plot[smooth] coordinates to do this.



      documentclass[tikz,border=7pt]{standalone}
      begin{document}
      begin{tikzpicture}[yscale=.5,
      sheet/.style={red,thick,smooth},
      point/.style={insert path={node[scale=4]{.}}}]
      % ---- sheets ----
      foreach[count=i] pts in {
      {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7,-1) (8, 0) (9, 0)},%
      {(0, 0) (1, 0) (2,-1) (3, 0) (6, 0) (7, 1) (8, 0) (9, 0)},%
      {(0, 0) (1, 0) (2, 1) (3, 0) (6, 0) (7,-2) (8, 0) (9, 0)},%
      {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 0) (8, 0) (9, 0)},%
      {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 2) (8, 0) (9, 0)},%
      {(0,0)},%
      {(0, 0) (9, 0)}%
      }{
      draw[yshift=-2*i cm,sheet] plot coordinates {pts};
      }
      % ---- singular points and labels ----
      path
      (2,-5) [point] (3,-5) node{$b=1$}
      (7,-3) [point] (8,-3) node{$b=1$}
      (7,-8) [point] (8,-7.5) node{$b=2$}
      ;
      % ---- vertical lines ----
      draw[dashed]
      (2,0) -- +(0,-14) [point]
      (7,0) -- +(0,-14) [point]
      ;
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer































        5














        This is a proof of concept how to use turtle library to define the following "moves" :





        • up make an up bump


        • up* make an up bump with (red) dot


        • dn make a down bump


        • dn* make a down bump with (red) dot


        • * put a (red) dot


        documentclass[tikz,border=7pt]{standalone}
        usetikzlibrary{turtle}
        tikzset{
        turtle/.cd,
        how/.style={out=0,in=180},
        home/.append style=right,
        */.style={/tikz/insert path={node[red,scale=4]{.}}},
        forward/.default=1.4142135,
        up/.style={left=45,forward,right,forward,left=45},
        up*/.style={left=45,forward,*,right,forward,left=45},
        dn/.style={right=45,forward,left,forward,right=45},
        dn*/.style={right=45,forward,*,left,forward,right=45},
        next/.style={/tikz/yshift=-1cm}
        }

        begin{document}
        tikz
        draw[thick]
        [turtle={home,fd,fd,fd,fd,fd,fd,dn,fd},next,next]
        [turtle={home,fd,fd,dn,fd,fd,up*,fd},next,next]
        [turtle={home,fd,fd,up*,fd,fd,dn,fd},next]
        [turtle={home,fd,fd,fd,fd,fd,fd,fd,fd,fd},next]
        [turtle={home,fd,fd,fd,fd,fd,fd,up*,fd}]
        ;
        end{document}


        enter image description here






        share|improve this answer































          5














          Edit notes:




          • spaces can now be handled, but are ignored by default


          • alternative syntax for myparserdef added





          Inspired by Kpym's answer but thinking that the possibilities of pgfparser are insufficient, I wrote my own parser, that should be similar to pgf's, but allows the parsed elements to grab arguments. The following arguments are supported:





          • m a mandatory argument


          • r{<delim>} a mandatory argument delimited by <delim>


          • o an optional argument in brackets (you can test for it with myIfNoValueTF)


          • O{<default>} an optional argument defaulting to <default>


          • d<delim1><delim2> an optional argument delimited by <delim1> and <delim2> (you can test for it with myIfNoValueTF)


          • D<delim1><delim2>{<default>} an optional argument delimited by <delim1> and <delim2> defaulting to <default>


          • t<token> an optional token (you can test for it with myIfBooleanTF)


          Despite the fact that the argument names are inspired by xparse, none of them care for balanced delimiters (e.g., [[ab]] would not be grabbed as [ab], but as [ab with an orphaned ], so you'd have to use [{[ab]}], this is like the LaTeX2e behaviour). Also all arguments are long by nature unlike xparse where you'd need to specify that using +.



          You can define a parser using myparserdef{<name>}{<state>}{<meaning>}[<args>]{<code>}, with <name> the name of the parser, <state> the state, <meaning> the meaning of a token, <args> an argument string (built from the arguments listed above, up to 9 arguments are supported) and <code> the code which should be executed for that combination of <name>, <state> and <meaning>. You can switch states using myparserstate{<state>}, if you switch to final parsing is ended, the initial state is initial. All in all this is pretty similar to pgfparsers way of doing things. The biggest difference is, that my parser ignores blanks by default, however you can define an action for blanks with myparserdef{<name>}{<state>}{blank space}[<args>]{<code>}. Many consecutive blanks are considered as one.



          You can also use a different syntax for myparserdef namely: myparserdef{<name>}{<state>}<token>[<args>]{<code>} with <token> being a single token not surrounded by {} (spaces are ignored here, it is not checked whether <token> is really a single token, so be careful). In that case the same will be done as if you'd typed the meaning of the <token>, so myparserdef{foo}{bar}a{baz} does the same as myparserdef{foo}{bar}{the letter a}{baz}.



          A parser is executed using myparserrun{<name>}. A parser needs at least one rule, else an error is thrown.



          This parser system allows me to place coordinates inside of sheet, which was the main reason why I found pgfparser insufficient.



          I did all of this without using any packages, only LaTeX-Kernel macros, just for procrastinating reasons. Using for example xparse would shorten the code considerably.



          documentclass[tikz,border=7pt]{standalone}

          % my parser >>>
          makeatletter
          % logic helpers >>>
          longdefmyfi@An#1fi#2{fi}
          longdefmyfi@Ay#1fi#2{fi#2}
          longdefmyfi@Byfi#1{fi#1}
          longdefmyfi@BTbfi#1#2#3{fi#2}
          % <<<
          % mynewdef >>>
          @ifdefinablemyifundefTF%>>>
          {%
          defmyifundefTF#1%
          {%
          ifdefined#1%
          myfi@Ay
          else
          myfi@BTb
          fi
          {%
          ifx#1relax
          myfi@BTb
          fi
          @secondoftwo
          }%
          }%
          }%<<<
          @ifdefinablemynewdef%>>>
          {%
          protecteddefmynewdef{@ifnextchar[{mynewdef@a}{mynewdef@a}}%
          }%<<<
          @ifdefinablemynewdef@a%>>>
          {%
          longdefmynewdef@a[#1]#2#3#{mynewdef@b{#1}#2{#3}}%
          }%<<<
          @ifdefinablemynewdef@b%>>>
          {%
          protectedlongdefmynewdef@b#1#2#3#4%
          {%
          myifundefTF#2%
          {%
          #1def#2#3{#4}%
          }
          {%
          PackageError{my}{Command string#2space already defined}{}%
          }
          }%
          }%<<<
          mynewdefmyifcsundefTF#1%>>>
          {%
          ifcsname #1endcsname
          myfi@Ay
          else
          myfi@BTb
          fi
          {%
          expandafterifxcsname #1endcsnamerelax
          myfi@BTb
          fi
          @secondoftwo
          }%
          }%<<<
          % <<<
          % opt arg parsing >>>
          mynewdef[long]my@ifmark#1%>>>
          {%
          ifxmy@mark#1%
          myfi@BTb
          fi
          @secondoftwo
          }%<<<
          mynewdef[protectedlong]myoarg@oarg#1%>>>
          {%
          @ifnextchar[{myoarg@oarg@{#1}}{#1{my@mark}}%
          }%<<<
          mynewdef[long]myoarg@oarg@#1[#2]%>>>
          {%
          #1{#2}%
          }%<<<
          mynewdef[protectedlong]myoarg@Oarg#1#2%>>>
          {%
          @ifnextchar[{myoarg@oarg@{#2}}{#2{#1}}%
          }%<<<
          mynewdef[protectedlong]myoarg@darg#1#2#3%>>>
          {%
          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
          @ifnextchar#1{myoarg@darg@{#3}}{#3{my@mark}}%
          }%<<<
          mynewdef[protectedlong]myoarg@Darg#1#2#3#4%>>>
          {%
          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
          @ifnextchar#1{myoarg@darg@{#4}}{#4{#3}}%
          }%<<<
          % <<<
          % macros for string comparison >>>
          begingroupdef:{endgroupletmy@sptoken= }:
          mynewdefmy@mark{my@mark@if@you@see@this@report@it}
          mynewdefmy@stop{my@stop@if@you@see@this@report@it}
          mynewdefmyparser@final{final}
          mynewdefmyparser@noarg{noarg}
          mynewdefmyparser@blankspace{blank space}
          % <<<
          mynewdef[protected]myparserdef#1#2%>>>
          {%
          defmyparserdef@twoargs{{#1}{#2}}%
          myparserdef@a
          }%<<<
          mynewdef[protected]myparserdef@a%>>>
          {%
          futureletmyparserdef@argmyparserdef@b
          }%<<<
          mynewdefmyparserdef@b%>>>
          {%
          ifxmyparserdef@argmy@sptoken
          myfi@BTb
          fi
          @secondoftwo
          {myparserdef@gobble@space}
          {myparserdef@c}%
          }%<<<
          mynewdef[protected]myparserdef@gobble@space%>>>
          {%
          afterassignmentmyparserdef@a
          letmyparserdef@arg= % space after = to get spaces, too
          }%<<<
          mynewdef[protected]myparserdef@c#1%>>>
          {%
          ifxmyparserdef@argbgroup
          myfi@BTb
          fi
          @secondoftwo
          {%
          defmyparserdef@arg{#1}%
          ifxmyparser@blankspacemyparserdef@arg
          myfi@BTb
          fi
          @secondoftwo
          {expandaftermyparserdef@dmyparserdef@twoargs{blank space space}}
          {expandaftermyparserdef@dmyparserdef@twoargs{#1}}%
          }
          {expandaftermyparserdef@dmyparserdef@twoargs{meaningmyparserdef@arg}}%
          }%<<<
          mynewdef[long]myparserdef@d#1#2#3%>>>
          {%
          myoarg@oarg{myparserdef@e{#1}{#2}{#3}}%
          }%<<<
          mynewdef[protectedlong]myparserdef@e#1#2#3#4#5%>>>
          {%
          % if that is the first rule for the parser, define space to be a no-op
          myifcsundefTF{myparser@name{#1}}%
          {%
          expandafterdef
          csname myparser@name{#1} all blank space spacespace typeendcsname
          {noarg}%
          expandafterdef
          csname myparser@name{#1} all blank space spacespace codeendcsname
          {myparser@getnexttoken}%
          % use a macro as a flag that there is at least one parser rule defined
          expandafterdefcsnamemyparser@name{#1}endcsname{}%
          }
          {}%
          % check whether the optional argument was used
          my@ifmark{#4}
          {%
          % use a macro as flag that there is a rule for the specified state
          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{noarg}%
          defmyparserdef@arg@count{0}%
          }
          {%
          edefmyparserdef@arg@count
          {thenumexprmyparserdef@argcount#4my@mark}%
          ifnummyparserdef@arg@count>9%
          PackageError{my}{Too many arguments for parser rule}
          {A maximum of 9 parameters is supported.}%
          else
          ifnummyparserdef@arg@count=0%
          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname
          {noarg}%
          else
          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{#4}%
          fi
          fi
          }%
          % define what the code does
          expandafterdefcsname myparser@name{#1} #2 #3 codeendcsname{}%
          expandafterrenewcommandcsname myparser@name{#1} #2 #3 codeendcsname
          [myparserdef@arg@count]{#5myparser@getnexttoken}%
          }%<<<
          mynewdefmyparserdef@argcount#1%>>>
          {%
          ifxmy@mark#1%
          myfi@An
          else
          myfi@By
          fi
          {csname myparserdef@argcount@#1endcsname}%
          }%<<<
          mynewdefmyparserdef@argcount@m%>>>
          {%
          +1%
          myparserdef@argcount
          }%<<<
          mynewdefmyparserdef@argcount@o%>>>
          {%
          +1%
          myparserdef@argcount
          }%<<<
          mynewdefmyparserdef@argcount@O#1%>>>
          {%
          +1%
          myparserdef@argcount
          }%<<<
          mynewdefmyparserdef@argcount@d#1#2%>>>
          {%
          +1%
          myparserdef@argcount
          }%<<<
          mynewdefmyparserdef@argcount@D#1#2#3%>>>
          {%
          +1%
          myparserdef@argcount
          }%<<<
          mynewdefmyparserdef@argcount@r#1%>>>
          {%
          +1%
          myparserdef@argcount
          }%<<<
          mynewdefmyparserdef@argcount@t#1%>>>
          {%
          +1%
          myparserdef@argcount
          }%<<<
          mynewdefmyparser@name#1%>>>
          {%
          myparser #1%
          }%<<<
          mynewdefmyparser@rule#1%>>>
          {%
          myparser@currentspace #1space meaningmyparser@token
          }%<<<
          mynewdefmyparser@type#1%>>>
          {%
          myparser@rule{#1} type%
          }%<<<
          mynewdefmyparser@code#1%>>>
          {%
          myparser@rule{#1} code%
          }%<<<
          mynewdef[protected]myparserrun#1%>>>
          {%
          myifcsundefTF{myparser@name{#1}}
          {PackageError{my}{No parser named '#1' defined}{}}
          {%
          edefmyparser@current{myparser@name{#1}}%
          defmyparser@usersname{#1}%
          defmyparser@state{initial}%
          myparser@getnexttoken
          }%
          }%<<<
          mynewdef[protected]myparser@getnexttoken%>>>
          {%
          ifxmyparser@statemyparser@final
          myfi@An
          else
          myfi@By
          fi
          {%
          afterassignmentmyparser@getnexttoken@a
          letmyparser@token= % space after = to get spaces, too
          }%
          }%<<<
          mynewdef[protected]myparser@getnexttoken@a%>>>
          {%
          myifcsundefTF{myparser@type{myparser@state}}
          {%
          myifcsundefTF{myparser@type{all}}
          {%
          PackageError{my}
          {%
          No rule for parser 'myparser@usersname' in state
          'myparser@state' for 'meaningmyparser@token'.
          Ignoring token%
          }
          {}%
          myparser@getnexttoken
          }
          {myparser@handle{all}}%
          }
          {myparser@handle{myparser@state}}%
          }%<<<
          mynewdef[protected]myparser@handle#1%>>>
          {%
          expandafterifxcsnamemyparser@type{#1}endcsnamemyparser@noarg
          myfi@BTb
          fi
          @secondoftwo
          {csnamemyparser@code{#1}endcsname}
          {myparser@handle@args{#1}}%
          }%<<<
          mynewdef[protected]myparserstate#1%>>>
          {%
          defmyparser@state{#1}%
          }%<<<
          mynewdef[protected]myparser@handle@args#1%>>>
          {%
          defmyparser@stateorall{#1}%
          expandafterexpandafterexpandaftermyparser@handle@args@a
          csnamemyparser@type{#1}endcsnamemy@markmy@stop
          }%<<<
          mynewdefmyparser@handle@args@a%>>>
          {%
          myparser@handle@args@b{}%
          }%<<<
          mynewdef[long]myparser@handle@args@b#1#2#3my@stop%>>>
          {%
          my@ifmark{#2}
          {csnamemyparser@code{myparser@stateorall}endcsname#1}
          {%
          myifcsundefTF{myparser@handle@args@#2}
          {PackageError{my}{Unknown argument type '#2'}{}}
          {csname myparser@handle@args@#2endcsname{#1}{#3}}%
          }%
          }%<<<
          mynewdef[long]myparser@handle@args@c#1#2%>>>
          {%
          my@ifmark{#2}
          {csnamemyparser@code{myparser@stateorall}endcsname#1}
          {myparser@handle@args@b{#1}#2my@stop}%
          }%<<<
          mynewdef[long]myparser@handle@args@m#1#2#3%>>>
          {%
          myparser@handle@args@c{#1{#3}}{#2}%
          }%<<<
          mynewdef[protectedlong]myparser@handle@args@o#1#2%>>>
          {%
          myoarg@oarg{myparser@handle@args@m{#1}{#2}}%
          }%<<<
          mynewdef[long]myparser@handle@args@O#1#2%>>>
          {%
          myparser@handle@args@O@{#1}#2my@stop
          }%<<<
          mynewdef[protectedlong]myparser@handle@args@O@#1#2#3my@stop%>>>
          {%
          myoarg@Oarg{#2}{myparser@handle@args@m{#1}{#3}}%
          }%<<<
          mynewdef[long]myparser@handle@args@d#1#2%>>>
          {%
          myparser@handle@args@d@{#1}#2my@stop
          }%<<<
          mynewdef[protectedlong]myparser@handle@args@d@#1#2#3#4my@stop%>>>
          {%
          myoarg@darg{#2}{#3}{myparser@handle@args@m{#1}{#4}}%
          }%<<<
          mynewdef[long]myparser@handle@args@D#1#2%>>>
          {%
          myparser@handle@args@D@{#1}#2my@stop
          }%<<<
          mynewdef[protectedlong]myparser@handle@args@D@#1#2#3#4#5my@stop%>>>
          {%
          myoarg@Darg{#2}{#3}{#4}{myparser@handle@args@m{#1}{#5}}%
          }%<<<
          mynewdef[long]myparser@handle@args@r#1#2%>>>
          {%
          myparser@handle@args@r@a{#1}#2my@stop
          }%<<<
          mynewdef[protectedlong]myparser@handle@args@r@a#1#2#3my@stop%>>>
          {%
          defmyparser@handle@args@r@b##1#2{myparser@handle@args@c{#1{##1}}{#3}}%
          myparser@handle@args@r@b
          }%<<<
          mynewdef[long]myparser@handle@args@t#1#2%>>>
          {%
          myparser@handle@args@t@a{#1}#2my@stop
          }%<<<
          mynewdef[protectedlong]myparser@handle@args@t@a#1#2#3my@stop%>>>
          {%
          @ifnextchar#2%
          {@firstoftwo{myparser@handle@args@c{#1{my@mark}}{#3}}}
          {myparser@handle@args@c{#1{my@stop}}{#3}}%
          }%<<<
          letmyIfNoValueTFmy@ifmark
          letmyIfBooleanTFmy@ifmark
          makeatother
          % <<<

          % the sheet path parser >>>
          makeatletter
          definsertpath#1{edefsheetpath@{unexpandedexpandafter{sheetpath@#1}}}
          defsheetpathcurve#1#2#3#4%
          {%
          to[out=0,in=180] ++({.5*sheetlength},{#1*sheetheight})
          myIfBooleanTF{#3}{}{node[scale=sheetdotsize,inner sep=0pt]{.}}
          myIfNoValueTF{#4}{}{coordinate({#4})}
          to[out=0,in=180] ++({.5*sheetlength},{#2*sheetheight})
          }
          defoutputpath{drawsheetpath@;}
          defsheet{defsheetpath@{}myparserrun{sheet path}}
          makeatother
          myparserdef{sheet path}{initial}{the character (}[r,r)]
          {insertpath{({#1},{#2*sheetheight})}myparserstate{started}}
          myparserdef{sheet path}{initial}{the character =}
          {insertpath{(0,0)--++(sheetlength,0)}myparserstate{started}}
          myparserdef{sheet path}{started}{the character (}[r)]
          {insertpath{coordinate({#1})}}
          myparserdef{sheet path}{started}{the character =}
          {insertpath{--++(sheetlength,0)}}
          myparserdef{sheet path}{started}{the letter u}[txd()]
          {insertpath{sheetpathcurve{.5}{-.5}{#1}{#2}}}
          myparserdef{sheet path}{started}{the letter U}[txd()]
          {insertpath{sheetpathcurve{1}{-1}{#1}{#2}}}
          myparserdef{sheet path}{started}{the letter d}[txd()]
          {insertpath{sheetpathcurve{-.5}{.5}{#1}{#2}}}
          myparserdef{sheet path}{started}{the letter D}[txd()]
          {insertpath{sheetpathcurve{-1}{1}{#1}{#2}}}
          % making '.' a no-op, that way we can use it to end the search for an optional
          % argument for instance
          myparserdef{sheet path}{started} .{}
          myparserdef{sheet path}{started}{the letter x}[d()]
          {%
          myIfNoValueTF{#1}
          {%
          insertpath
          {--node[scale=sheetdotsize,inner sep=0pt]{.}++(sheetlength,0)}%
          }
          {%
          insertpath
          {%
          --node[scale=sheetdotsize,inner sep=0pt]{.}
          coordinate({#1})
          ++(sheetlength,0)
          }%
          }%
          }
          myparserdef{sheet path}{all}{the character ;}{myparserstate{final}outputpath}
          % <<<

          % sheet height and sheet length >>>
          pgfset
          {
          ,sheet height/.store in=sheetheight
          ,sheet height=1
          ,sheet length/.store in=sheetlength
          ,sheet length=1
          ,sheet dot size/.store in=sheetdotsize
          ,sheet dot size=4
          }
          %<<<

          begin{document}
          begin{tikzpicture}
          begin{scope}[thick, sheet height=0.75]
          sheet === ===d(sp1)=;
          sheet (0,-1) ==d(sp2)===ux =;
          sheet (0,-2) ==ux ===Dx =;
          sheet (0,-3) === ==== =;
          sheet (0,-4) === ===U(sp3)=;
          sheet (0,-5.5) ==x(b1) ===x(b2) =;
          end{scope}
          draw[dashed]
          (b2) -- (sp1)
          (b1) -- (sp2)
          ;
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer


























          • Wow ! This is a huge work. I'm impressed (like always I'm by the texperts ;)).

            – Kpym
            4 hours ago











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481125%2fdrawing-ramified-coverings-with-tikz%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          7 Answers
          7






          active

          oldest

          votes








          7 Answers
          7






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          13














          This uses the same in and out trick as Skillmon and puts it into a style dip, which takes as arguments the horizontal position and the depth, where the sign decides whether the dip is a dip (minus) or a bump (plus). (Let me also mention that you do not need to do something like draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};. If you name the nodes, you can just do draw[<-] (Y) -- (X) node[left, midway] {$f$}; and TikZ will make sure to shorten the arrow without you having to compute the coordinates.)



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{positioning}
          newcounter{dip}
          begin{document}
          begin{tikzpicture}[dip/.style args={#1/#2}{/utils/exec=stepcounter{dip},
          insert path={%
          coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3)
          (aux1) -- (aux2|-aux1) to[out=0,in=180]
          ++({abs(#2)},#2) coordinate(dip-thevalue{dip}) to[out=0,in=180] (aux3|-aux1)
          }}]
          begin{scope}[thick,local bounding box=dips]
          draw (1,2.5) [dip=5.5cm/-2.5mm]-- (7,2.5);
          fill (dip-1) circle[radius=2pt] node[right=3pt]{$b=1$};
          draw (1,2) [dip/.list={2.5cm/-2.5mm,5.5cm/2.5mm}] -- (7,2);
          fill (dip-2) circle[radius=2pt] node[right=3pt]{$b=1$};
          draw (1,1.5) [dip/.list={2.5cm/2.5mm,5.5cm/-5mm}] -- (7,1.5);
          fill (dip-5) circle[radius=2pt] node[above right=0pt and 5pt]{$b=2$};
          draw (1,1) -- (7,1);
          draw (1,0.5) [dip=5.5cm/5mm] -- (7,0.5);
          end{scope}
          node[left=2pt of dips.west] (X) {$X$};
          draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
          draw[<-] (Y) -- (X) node[left, midway] {$f$};
          foreach X in {1,2}
          {
          fill (dip-X|-Y) circle[radius=2pt];
          draw[dashed] (dip-X|-Y) -- (dip-X|-0,2.75);
          }
          end{tikzpicture}
          end{document}


          enter image description here



          Just for fun: a variation for Skillmon.



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{positioning}
          newcounter{dip}
          begin{document}
          begin{tikzpicture}[dip/.style={/utils/exec=stepcounter{dip},
          insert path={%
          to[out=0,in=180]
          ++(0.25,#1) node[bullet](dip-thevalue{dip}){}
          to[out=0,in=180] ++(0.25,-1*#1)
          }},bullet/.style={circle,fill,inner sep=1.5pt}]
          begin{scope}[thick,local bounding box=dips]
          draw (1,2.5) -- (5.25,2.5) [dip=-2.5mm]-- (7,2.5);
          node[right=3pt of dip-1]{$b=1$};
          draw (1,2) -- (2.25,2) [dip=-2.5mm] -- (5.25,2) [dip=2.5mm] --(7,2);
          node[right=3pt of dip-2]{$b=1$};
          draw (1,1.5) -- (2.25,1.5) [dip=2.5mm] --(5.25,1.5) [dip=-5mm] -- (7,1.5);
          node[above right=-1.5pt and 5pt of dip-5]{$b=2$};
          draw (1,1) -- (7,1);
          draw (1,0.5) --(5.25,0.5) [dip=5mm] -- (7,0.5);
          end{scope}
          node[left=2pt of dips.west] (X) {$X$};
          draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
          draw[<-] (Y) -- (X) node[left, midway] {$f$};
          foreach X in {1,2}
          {
          draw[dashed] (dip-X|-Y) node[bullet]{} -- (dip-X|-0,2.75);
          }
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer


























          • Very nice automation. Just out of curiosity (coding TikZ is still something I'm not good at), is it possible to also draw the filled circles inside the dip style?

            – Skillmon
            yesterday






          • 1





            @Skillmon Yes, of course. E.g. dip/.style args={#1/#2}{/utils/exec=stepcounter{dip}, insert path={% coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3) (aux1) -- (aux2|-aux1) to[out=0,in=180] ++({abs(#2)},#2) node[circle,fill,inner sep=1.5pt](dip-thevalue{dip}){} to[out=0,in=180] (aux3|-aux1) }}.

            – marmot
            yesterday
















          13














          This uses the same in and out trick as Skillmon and puts it into a style dip, which takes as arguments the horizontal position and the depth, where the sign decides whether the dip is a dip (minus) or a bump (plus). (Let me also mention that you do not need to do something like draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};. If you name the nodes, you can just do draw[<-] (Y) -- (X) node[left, midway] {$f$}; and TikZ will make sure to shorten the arrow without you having to compute the coordinates.)



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{positioning}
          newcounter{dip}
          begin{document}
          begin{tikzpicture}[dip/.style args={#1/#2}{/utils/exec=stepcounter{dip},
          insert path={%
          coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3)
          (aux1) -- (aux2|-aux1) to[out=0,in=180]
          ++({abs(#2)},#2) coordinate(dip-thevalue{dip}) to[out=0,in=180] (aux3|-aux1)
          }}]
          begin{scope}[thick,local bounding box=dips]
          draw (1,2.5) [dip=5.5cm/-2.5mm]-- (7,2.5);
          fill (dip-1) circle[radius=2pt] node[right=3pt]{$b=1$};
          draw (1,2) [dip/.list={2.5cm/-2.5mm,5.5cm/2.5mm}] -- (7,2);
          fill (dip-2) circle[radius=2pt] node[right=3pt]{$b=1$};
          draw (1,1.5) [dip/.list={2.5cm/2.5mm,5.5cm/-5mm}] -- (7,1.5);
          fill (dip-5) circle[radius=2pt] node[above right=0pt and 5pt]{$b=2$};
          draw (1,1) -- (7,1);
          draw (1,0.5) [dip=5.5cm/5mm] -- (7,0.5);
          end{scope}
          node[left=2pt of dips.west] (X) {$X$};
          draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
          draw[<-] (Y) -- (X) node[left, midway] {$f$};
          foreach X in {1,2}
          {
          fill (dip-X|-Y) circle[radius=2pt];
          draw[dashed] (dip-X|-Y) -- (dip-X|-0,2.75);
          }
          end{tikzpicture}
          end{document}


          enter image description here



          Just for fun: a variation for Skillmon.



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{positioning}
          newcounter{dip}
          begin{document}
          begin{tikzpicture}[dip/.style={/utils/exec=stepcounter{dip},
          insert path={%
          to[out=0,in=180]
          ++(0.25,#1) node[bullet](dip-thevalue{dip}){}
          to[out=0,in=180] ++(0.25,-1*#1)
          }},bullet/.style={circle,fill,inner sep=1.5pt}]
          begin{scope}[thick,local bounding box=dips]
          draw (1,2.5) -- (5.25,2.5) [dip=-2.5mm]-- (7,2.5);
          node[right=3pt of dip-1]{$b=1$};
          draw (1,2) -- (2.25,2) [dip=-2.5mm] -- (5.25,2) [dip=2.5mm] --(7,2);
          node[right=3pt of dip-2]{$b=1$};
          draw (1,1.5) -- (2.25,1.5) [dip=2.5mm] --(5.25,1.5) [dip=-5mm] -- (7,1.5);
          node[above right=-1.5pt and 5pt of dip-5]{$b=2$};
          draw (1,1) -- (7,1);
          draw (1,0.5) --(5.25,0.5) [dip=5mm] -- (7,0.5);
          end{scope}
          node[left=2pt of dips.west] (X) {$X$};
          draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
          draw[<-] (Y) -- (X) node[left, midway] {$f$};
          foreach X in {1,2}
          {
          draw[dashed] (dip-X|-Y) node[bullet]{} -- (dip-X|-0,2.75);
          }
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer


























          • Very nice automation. Just out of curiosity (coding TikZ is still something I'm not good at), is it possible to also draw the filled circles inside the dip style?

            – Skillmon
            yesterday






          • 1





            @Skillmon Yes, of course. E.g. dip/.style args={#1/#2}{/utils/exec=stepcounter{dip}, insert path={% coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3) (aux1) -- (aux2|-aux1) to[out=0,in=180] ++({abs(#2)},#2) node[circle,fill,inner sep=1.5pt](dip-thevalue{dip}){} to[out=0,in=180] (aux3|-aux1) }}.

            – marmot
            yesterday














          13












          13








          13







          This uses the same in and out trick as Skillmon and puts it into a style dip, which takes as arguments the horizontal position and the depth, where the sign decides whether the dip is a dip (minus) or a bump (plus). (Let me also mention that you do not need to do something like draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};. If you name the nodes, you can just do draw[<-] (Y) -- (X) node[left, midway] {$f$}; and TikZ will make sure to shorten the arrow without you having to compute the coordinates.)



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{positioning}
          newcounter{dip}
          begin{document}
          begin{tikzpicture}[dip/.style args={#1/#2}{/utils/exec=stepcounter{dip},
          insert path={%
          coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3)
          (aux1) -- (aux2|-aux1) to[out=0,in=180]
          ++({abs(#2)},#2) coordinate(dip-thevalue{dip}) to[out=0,in=180] (aux3|-aux1)
          }}]
          begin{scope}[thick,local bounding box=dips]
          draw (1,2.5) [dip=5.5cm/-2.5mm]-- (7,2.5);
          fill (dip-1) circle[radius=2pt] node[right=3pt]{$b=1$};
          draw (1,2) [dip/.list={2.5cm/-2.5mm,5.5cm/2.5mm}] -- (7,2);
          fill (dip-2) circle[radius=2pt] node[right=3pt]{$b=1$};
          draw (1,1.5) [dip/.list={2.5cm/2.5mm,5.5cm/-5mm}] -- (7,1.5);
          fill (dip-5) circle[radius=2pt] node[above right=0pt and 5pt]{$b=2$};
          draw (1,1) -- (7,1);
          draw (1,0.5) [dip=5.5cm/5mm] -- (7,0.5);
          end{scope}
          node[left=2pt of dips.west] (X) {$X$};
          draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
          draw[<-] (Y) -- (X) node[left, midway] {$f$};
          foreach X in {1,2}
          {
          fill (dip-X|-Y) circle[radius=2pt];
          draw[dashed] (dip-X|-Y) -- (dip-X|-0,2.75);
          }
          end{tikzpicture}
          end{document}


          enter image description here



          Just for fun: a variation for Skillmon.



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{positioning}
          newcounter{dip}
          begin{document}
          begin{tikzpicture}[dip/.style={/utils/exec=stepcounter{dip},
          insert path={%
          to[out=0,in=180]
          ++(0.25,#1) node[bullet](dip-thevalue{dip}){}
          to[out=0,in=180] ++(0.25,-1*#1)
          }},bullet/.style={circle,fill,inner sep=1.5pt}]
          begin{scope}[thick,local bounding box=dips]
          draw (1,2.5) -- (5.25,2.5) [dip=-2.5mm]-- (7,2.5);
          node[right=3pt of dip-1]{$b=1$};
          draw (1,2) -- (2.25,2) [dip=-2.5mm] -- (5.25,2) [dip=2.5mm] --(7,2);
          node[right=3pt of dip-2]{$b=1$};
          draw (1,1.5) -- (2.25,1.5) [dip=2.5mm] --(5.25,1.5) [dip=-5mm] -- (7,1.5);
          node[above right=-1.5pt and 5pt of dip-5]{$b=2$};
          draw (1,1) -- (7,1);
          draw (1,0.5) --(5.25,0.5) [dip=5mm] -- (7,0.5);
          end{scope}
          node[left=2pt of dips.west] (X) {$X$};
          draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
          draw[<-] (Y) -- (X) node[left, midway] {$f$};
          foreach X in {1,2}
          {
          draw[dashed] (dip-X|-Y) node[bullet]{} -- (dip-X|-0,2.75);
          }
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer















          This uses the same in and out trick as Skillmon and puts it into a style dip, which takes as arguments the horizontal position and the depth, where the sign decides whether the dip is a dip (minus) or a bump (plus). (Let me also mention that you do not need to do something like draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};. If you name the nodes, you can just do draw[<-] (Y) -- (X) node[left, midway] {$f$}; and TikZ will make sure to shorten the arrow without you having to compute the coordinates.)



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{positioning}
          newcounter{dip}
          begin{document}
          begin{tikzpicture}[dip/.style args={#1/#2}{/utils/exec=stepcounter{dip},
          insert path={%
          coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3)
          (aux1) -- (aux2|-aux1) to[out=0,in=180]
          ++({abs(#2)},#2) coordinate(dip-thevalue{dip}) to[out=0,in=180] (aux3|-aux1)
          }}]
          begin{scope}[thick,local bounding box=dips]
          draw (1,2.5) [dip=5.5cm/-2.5mm]-- (7,2.5);
          fill (dip-1) circle[radius=2pt] node[right=3pt]{$b=1$};
          draw (1,2) [dip/.list={2.5cm/-2.5mm,5.5cm/2.5mm}] -- (7,2);
          fill (dip-2) circle[radius=2pt] node[right=3pt]{$b=1$};
          draw (1,1.5) [dip/.list={2.5cm/2.5mm,5.5cm/-5mm}] -- (7,1.5);
          fill (dip-5) circle[radius=2pt] node[above right=0pt and 5pt]{$b=2$};
          draw (1,1) -- (7,1);
          draw (1,0.5) [dip=5.5cm/5mm] -- (7,0.5);
          end{scope}
          node[left=2pt of dips.west] (X) {$X$};
          draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
          draw[<-] (Y) -- (X) node[left, midway] {$f$};
          foreach X in {1,2}
          {
          fill (dip-X|-Y) circle[radius=2pt];
          draw[dashed] (dip-X|-Y) -- (dip-X|-0,2.75);
          }
          end{tikzpicture}
          end{document}


          enter image description here



          Just for fun: a variation for Skillmon.



          documentclass[tikz,border=3.14mm]{standalone}
          usetikzlibrary{positioning}
          newcounter{dip}
          begin{document}
          begin{tikzpicture}[dip/.style={/utils/exec=stepcounter{dip},
          insert path={%
          to[out=0,in=180]
          ++(0.25,#1) node[bullet](dip-thevalue{dip}){}
          to[out=0,in=180] ++(0.25,-1*#1)
          }},bullet/.style={circle,fill,inner sep=1.5pt}]
          begin{scope}[thick,local bounding box=dips]
          draw (1,2.5) -- (5.25,2.5) [dip=-2.5mm]-- (7,2.5);
          node[right=3pt of dip-1]{$b=1$};
          draw (1,2) -- (2.25,2) [dip=-2.5mm] -- (5.25,2) [dip=2.5mm] --(7,2);
          node[right=3pt of dip-2]{$b=1$};
          draw (1,1.5) -- (2.25,1.5) [dip=2.5mm] --(5.25,1.5) [dip=-5mm] -- (7,1.5);
          node[above right=-1.5pt and 5pt of dip-5]{$b=2$};
          draw (1,1) -- (7,1);
          draw (1,0.5) --(5.25,0.5) [dip=5mm] -- (7,0.5);
          end{scope}
          node[left=2pt of dips.west] (X) {$X$};
          draw (7,-0.5) -- (1,-0.5) node[left=2pt] (Y) {$Y$};
          draw[<-] (Y) -- (X) node[left, midway] {$f$};
          foreach X in {1,2}
          {
          draw[dashed] (dip-X|-Y) node[bullet]{} -- (dip-X|-0,2.75);
          }
          end{tikzpicture}
          end{document}


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited yesterday

























          answered 2 days ago









          marmotmarmot

          111k5140264




          111k5140264













          • Very nice automation. Just out of curiosity (coding TikZ is still something I'm not good at), is it possible to also draw the filled circles inside the dip style?

            – Skillmon
            yesterday






          • 1





            @Skillmon Yes, of course. E.g. dip/.style args={#1/#2}{/utils/exec=stepcounter{dip}, insert path={% coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3) (aux1) -- (aux2|-aux1) to[out=0,in=180] ++({abs(#2)},#2) node[circle,fill,inner sep=1.5pt](dip-thevalue{dip}){} to[out=0,in=180] (aux3|-aux1) }}.

            – marmot
            yesterday



















          • Very nice automation. Just out of curiosity (coding TikZ is still something I'm not good at), is it possible to also draw the filled circles inside the dip style?

            – Skillmon
            yesterday






          • 1





            @Skillmon Yes, of course. E.g. dip/.style args={#1/#2}{/utils/exec=stepcounter{dip}, insert path={% coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3) (aux1) -- (aux2|-aux1) to[out=0,in=180] ++({abs(#2)},#2) node[circle,fill,inner sep=1.5pt](dip-thevalue{dip}){} to[out=0,in=180] (aux3|-aux1) }}.

            – marmot
            yesterday

















          Very nice automation. Just out of curiosity (coding TikZ is still something I'm not good at), is it possible to also draw the filled circles inside the dip style?

          – Skillmon
          yesterday





          Very nice automation. Just out of curiosity (coding TikZ is still something I'm not good at), is it possible to also draw the filled circles inside the dip style?

          – Skillmon
          yesterday




          1




          1





          @Skillmon Yes, of course. E.g. dip/.style args={#1/#2}{/utils/exec=stepcounter{dip}, insert path={% coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3) (aux1) -- (aux2|-aux1) to[out=0,in=180] ++({abs(#2)},#2) node[circle,fill,inner sep=1.5pt](dip-thevalue{dip}){} to[out=0,in=180] (aux3|-aux1) }}.

          – marmot
          yesterday





          @Skillmon Yes, of course. E.g. dip/.style args={#1/#2}{/utils/exec=stepcounter{dip}, insert path={% coordinate (aux1) ({#1-abs(#2)},0) coordinate (aux2) ({#1+abs(#2)},0) coordinate (aux3) (aux1) -- (aux2|-aux1) to[out=0,in=180] ++({abs(#2)},#2) node[circle,fill,inner sep=1.5pt](dip-thevalue{dip}){} to[out=0,in=180] (aux3|-aux1) }}.

          – marmot
          yesterday











          11














          The following is a pretty manual way to do this. I only did it for the first two lines, I hope you can apply it to the other occurrences. It uses the in and out keys of the to path construction:



          documentclass[tikz]{standalone}

          begin{document}
          begin{tikzpicture}
          draw (0,0) node {$Y$};
          draw (0,2) node {$X$};
          draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};
          draw[thick] (1,2.5) -- (7,2.5) coordinate(a);
          draw[thick] (1,2) -- (7,2) coordinate(b);
          draw[thick] (1,1.5) -- (7,1.5) coordinate(c);
          draw[thick] (1,0) -- (7,0) coordinate(d);
          draw[thick]
          (a) ++(.25,-.25) coordinate(ab) to[out=180,in=0] (a)
          (ab) to[out=180,in=0] (b)
          (ab) to[out=0,in=180] ++(.25,.25)
          (ab) to[out=0,in=180] ++(.25,-.25)
          ;
          filldraw
          (ab) circle(.05)
          ;
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer






























            11














            The following is a pretty manual way to do this. I only did it for the first two lines, I hope you can apply it to the other occurrences. It uses the in and out keys of the to path construction:



            documentclass[tikz]{standalone}

            begin{document}
            begin{tikzpicture}
            draw (0,0) node {$Y$};
            draw (0,2) node {$X$};
            draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};
            draw[thick] (1,2.5) -- (7,2.5) coordinate(a);
            draw[thick] (1,2) -- (7,2) coordinate(b);
            draw[thick] (1,1.5) -- (7,1.5) coordinate(c);
            draw[thick] (1,0) -- (7,0) coordinate(d);
            draw[thick]
            (a) ++(.25,-.25) coordinate(ab) to[out=180,in=0] (a)
            (ab) to[out=180,in=0] (b)
            (ab) to[out=0,in=180] ++(.25,.25)
            (ab) to[out=0,in=180] ++(.25,-.25)
            ;
            filldraw
            (ab) circle(.05)
            ;
            end{tikzpicture}
            end{document}


            enter image description here






            share|improve this answer




























              11












              11








              11







              The following is a pretty manual way to do this. I only did it for the first two lines, I hope you can apply it to the other occurrences. It uses the in and out keys of the to path construction:



              documentclass[tikz]{standalone}

              begin{document}
              begin{tikzpicture}
              draw (0,0) node {$Y$};
              draw (0,2) node {$X$};
              draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};
              draw[thick] (1,2.5) -- (7,2.5) coordinate(a);
              draw[thick] (1,2) -- (7,2) coordinate(b);
              draw[thick] (1,1.5) -- (7,1.5) coordinate(c);
              draw[thick] (1,0) -- (7,0) coordinate(d);
              draw[thick]
              (a) ++(.25,-.25) coordinate(ab) to[out=180,in=0] (a)
              (ab) to[out=180,in=0] (b)
              (ab) to[out=0,in=180] ++(.25,.25)
              (ab) to[out=0,in=180] ++(.25,-.25)
              ;
              filldraw
              (ab) circle(.05)
              ;
              end{tikzpicture}
              end{document}


              enter image description here






              share|improve this answer















              The following is a pretty manual way to do this. I only did it for the first two lines, I hope you can apply it to the other occurrences. It uses the in and out keys of the to path construction:



              documentclass[tikz]{standalone}

              begin{document}
              begin{tikzpicture}
              draw (0,0) node {$Y$};
              draw (0,2) node {$X$};
              draw[<-] (0,0.35) -- (0,1.65) node[left, midway] {$f$};
              draw[thick] (1,2.5) -- (7,2.5) coordinate(a);
              draw[thick] (1,2) -- (7,2) coordinate(b);
              draw[thick] (1,1.5) -- (7,1.5) coordinate(c);
              draw[thick] (1,0) -- (7,0) coordinate(d);
              draw[thick]
              (a) ++(.25,-.25) coordinate(ab) to[out=180,in=0] (a)
              (ab) to[out=180,in=0] (b)
              (ab) to[out=0,in=180] ++(.25,.25)
              (ab) to[out=0,in=180] ++(.25,-.25)
              ;
              filldraw
              (ab) circle(.05)
              ;
              end{tikzpicture}
              end{document}


              enter image description here







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited 2 days ago

























              answered 2 days ago









              SkillmonSkillmon

              23.8k12248




              23.8k12248























                  10














                  This is a proof of concept how to use parser library to define the following "language" :





                  • = stay at the same level


                  • u goes half up


                  • U goes one up


                  • d goes half down


                  • D goes one down


                  • x plot a (red) dot


                  • . end


                  Here is the code.



                  documentclass[tikz,border=7pt]{standalone}
                  usepgfmodule{parser}
                  % -----------------------------
                  % macro that add #1 to the current path when used inside pgfextra
                  definsertpath#1{tikzset{insert path={#1}}}
                  % define the parser "sheet path"
                  pgfparserdef{sheet path}{initial}{the character =}{insertpath{ -- ++(1, 0)}}
                  pgfparserdef{sheet path}{initial}{the letter u}{insertpath{ to[out=0,in=180] ++(1, .5)}}
                  pgfparserdef{sheet path}{initial}{the letter U}{insertpath{ to[out=0,in=180] ++(1, 1)}}
                  pgfparserdef{sheet path}{initial}{the letter d}{insertpath{ to[out=0,in=180] ++(1,-.5)}}
                  pgfparserdef{sheet path}{initial}{the letter D}{insertpath{ to[out=0,in=180] ++(1, -1)}}
                  pgfparserdef{sheet path}{initial}{the letter x}{insertpath{ node[red,scale=4]{.}}}
                  pgfparserdef{sheet path}{initial}{the character .}{pgfparserswitch{final}}
                  % the sheet interface macro
                  defsheet#1.{pgfextra{pgfparserparse{sheet path}#1.}}
                  % -----------------------------
                  begin{document}
                  tikzdraw[thick]
                  (0,-1) sheet======du=.
                  (0,-2) sheet==du==uxd=.
                  (0,-3) sheet==uxd==DU=.
                  (0,-4) sheet=========.
                  (0,-5) sheet======UxD=.;
                  end{document}


                  enter image description here






                  share|improve this answer



















                  • 3





                    +1, I didn't know parser, wow!

                    – CarLaTeX
                    yesterday
















                  10














                  This is a proof of concept how to use parser library to define the following "language" :





                  • = stay at the same level


                  • u goes half up


                  • U goes one up


                  • d goes half down


                  • D goes one down


                  • x plot a (red) dot


                  • . end


                  Here is the code.



                  documentclass[tikz,border=7pt]{standalone}
                  usepgfmodule{parser}
                  % -----------------------------
                  % macro that add #1 to the current path when used inside pgfextra
                  definsertpath#1{tikzset{insert path={#1}}}
                  % define the parser "sheet path"
                  pgfparserdef{sheet path}{initial}{the character =}{insertpath{ -- ++(1, 0)}}
                  pgfparserdef{sheet path}{initial}{the letter u}{insertpath{ to[out=0,in=180] ++(1, .5)}}
                  pgfparserdef{sheet path}{initial}{the letter U}{insertpath{ to[out=0,in=180] ++(1, 1)}}
                  pgfparserdef{sheet path}{initial}{the letter d}{insertpath{ to[out=0,in=180] ++(1,-.5)}}
                  pgfparserdef{sheet path}{initial}{the letter D}{insertpath{ to[out=0,in=180] ++(1, -1)}}
                  pgfparserdef{sheet path}{initial}{the letter x}{insertpath{ node[red,scale=4]{.}}}
                  pgfparserdef{sheet path}{initial}{the character .}{pgfparserswitch{final}}
                  % the sheet interface macro
                  defsheet#1.{pgfextra{pgfparserparse{sheet path}#1.}}
                  % -----------------------------
                  begin{document}
                  tikzdraw[thick]
                  (0,-1) sheet======du=.
                  (0,-2) sheet==du==uxd=.
                  (0,-3) sheet==uxd==DU=.
                  (0,-4) sheet=========.
                  (0,-5) sheet======UxD=.;
                  end{document}


                  enter image description here






                  share|improve this answer



















                  • 3





                    +1, I didn't know parser, wow!

                    – CarLaTeX
                    yesterday














                  10












                  10








                  10







                  This is a proof of concept how to use parser library to define the following "language" :





                  • = stay at the same level


                  • u goes half up


                  • U goes one up


                  • d goes half down


                  • D goes one down


                  • x plot a (red) dot


                  • . end


                  Here is the code.



                  documentclass[tikz,border=7pt]{standalone}
                  usepgfmodule{parser}
                  % -----------------------------
                  % macro that add #1 to the current path when used inside pgfextra
                  definsertpath#1{tikzset{insert path={#1}}}
                  % define the parser "sheet path"
                  pgfparserdef{sheet path}{initial}{the character =}{insertpath{ -- ++(1, 0)}}
                  pgfparserdef{sheet path}{initial}{the letter u}{insertpath{ to[out=0,in=180] ++(1, .5)}}
                  pgfparserdef{sheet path}{initial}{the letter U}{insertpath{ to[out=0,in=180] ++(1, 1)}}
                  pgfparserdef{sheet path}{initial}{the letter d}{insertpath{ to[out=0,in=180] ++(1,-.5)}}
                  pgfparserdef{sheet path}{initial}{the letter D}{insertpath{ to[out=0,in=180] ++(1, -1)}}
                  pgfparserdef{sheet path}{initial}{the letter x}{insertpath{ node[red,scale=4]{.}}}
                  pgfparserdef{sheet path}{initial}{the character .}{pgfparserswitch{final}}
                  % the sheet interface macro
                  defsheet#1.{pgfextra{pgfparserparse{sheet path}#1.}}
                  % -----------------------------
                  begin{document}
                  tikzdraw[thick]
                  (0,-1) sheet======du=.
                  (0,-2) sheet==du==uxd=.
                  (0,-3) sheet==uxd==DU=.
                  (0,-4) sheet=========.
                  (0,-5) sheet======UxD=.;
                  end{document}


                  enter image description here






                  share|improve this answer













                  This is a proof of concept how to use parser library to define the following "language" :





                  • = stay at the same level


                  • u goes half up


                  • U goes one up


                  • d goes half down


                  • D goes one down


                  • x plot a (red) dot


                  • . end


                  Here is the code.



                  documentclass[tikz,border=7pt]{standalone}
                  usepgfmodule{parser}
                  % -----------------------------
                  % macro that add #1 to the current path when used inside pgfextra
                  definsertpath#1{tikzset{insert path={#1}}}
                  % define the parser "sheet path"
                  pgfparserdef{sheet path}{initial}{the character =}{insertpath{ -- ++(1, 0)}}
                  pgfparserdef{sheet path}{initial}{the letter u}{insertpath{ to[out=0,in=180] ++(1, .5)}}
                  pgfparserdef{sheet path}{initial}{the letter U}{insertpath{ to[out=0,in=180] ++(1, 1)}}
                  pgfparserdef{sheet path}{initial}{the letter d}{insertpath{ to[out=0,in=180] ++(1,-.5)}}
                  pgfparserdef{sheet path}{initial}{the letter D}{insertpath{ to[out=0,in=180] ++(1, -1)}}
                  pgfparserdef{sheet path}{initial}{the letter x}{insertpath{ node[red,scale=4]{.}}}
                  pgfparserdef{sheet path}{initial}{the character .}{pgfparserswitch{final}}
                  % the sheet interface macro
                  defsheet#1.{pgfextra{pgfparserparse{sheet path}#1.}}
                  % -----------------------------
                  begin{document}
                  tikzdraw[thick]
                  (0,-1) sheet======du=.
                  (0,-2) sheet==du==uxd=.
                  (0,-3) sheet==uxd==DU=.
                  (0,-4) sheet=========.
                  (0,-5) sheet======UxD=.;
                  end{document}


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  KpymKpym

                  17k24090




                  17k24090








                  • 3





                    +1, I didn't know parser, wow!

                    – CarLaTeX
                    yesterday














                  • 3





                    +1, I didn't know parser, wow!

                    – CarLaTeX
                    yesterday








                  3




                  3





                  +1, I didn't know parser, wow!

                  – CarLaTeX
                  yesterday





                  +1, I didn't know parser, wow!

                  – CarLaTeX
                  yesterday











                  9














                  I think Bézier curves can do the task. It can make sure that the starting points and the ending points of all curves are placed with a consistent ratio.



                  documentclass[tikz]{standalone}
                  definnersep{.5em}
                  usetikzlibrary{patterns}
                  begin{document}
                  begin{tikzpicture}[y=baselineskip+2*innersep]
                  draw (0,0)--(6.5,0);
                  draw (0,1.5)--(6.5,1.5);
                  draw (0,1)--(4.75,1) .. controls (4.9,1) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,1) .. (5.25,1)--(6.5,1);
                  draw (0,2)--(1.25,2) .. controls (1.4,2) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2) .. (1.75,2)--(4.75,2) .. controls (4.9,2) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,2) .. (5.25,2)--(6.5,2);
                  draw (0,2.5)--(1.25,2.5) .. controls (1.4,2.5) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2.5) .. (1.75,2.5)--(4.75,2.5) .. controls (4.9,2.5) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,2.5) .. (5.25,2.5)--(6.5,2.5);
                  draw (0,3)--(4.75,3) .. controls (4.9,3) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,3) .. (5.25,3)--(6.5,3);
                  fill (1.5,2.25) circle (1.5pt) (5,1.5) circle (1.5pt) (5,2.75) circle (1.5pt) (1.5,0) circle (1.5pt) (5,0) circle (1.5pt);
                  draw[dashed] (1.5,0)--(1.5,3.25) (5,0)--(5,3.25);
                  draw (1.5,2.25) node[right=1ex] {$b=1$};
                  draw (5,1.75) node[right=1ex] {$b=2$};
                  draw (5,2.75) node[right=1ex] {$b=1$};
                  draw (-0.5,0) node (n) {$N$};
                  draw (-0.5,2.25) node (m) {$M$};
                  draw[-latex] (m)--(n) node[midway,left] {$f$};
                  end{tikzpicture}
                  end{document}


                  enter image description here






                  share|improve this answer




























                    9














                    I think Bézier curves can do the task. It can make sure that the starting points and the ending points of all curves are placed with a consistent ratio.



                    documentclass[tikz]{standalone}
                    definnersep{.5em}
                    usetikzlibrary{patterns}
                    begin{document}
                    begin{tikzpicture}[y=baselineskip+2*innersep]
                    draw (0,0)--(6.5,0);
                    draw (0,1.5)--(6.5,1.5);
                    draw (0,1)--(4.75,1) .. controls (4.9,1) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,1) .. (5.25,1)--(6.5,1);
                    draw (0,2)--(1.25,2) .. controls (1.4,2) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2) .. (1.75,2)--(4.75,2) .. controls (4.9,2) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,2) .. (5.25,2)--(6.5,2);
                    draw (0,2.5)--(1.25,2.5) .. controls (1.4,2.5) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2.5) .. (1.75,2.5)--(4.75,2.5) .. controls (4.9,2.5) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,2.5) .. (5.25,2.5)--(6.5,2.5);
                    draw (0,3)--(4.75,3) .. controls (4.9,3) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,3) .. (5.25,3)--(6.5,3);
                    fill (1.5,2.25) circle (1.5pt) (5,1.5) circle (1.5pt) (5,2.75) circle (1.5pt) (1.5,0) circle (1.5pt) (5,0) circle (1.5pt);
                    draw[dashed] (1.5,0)--(1.5,3.25) (5,0)--(5,3.25);
                    draw (1.5,2.25) node[right=1ex] {$b=1$};
                    draw (5,1.75) node[right=1ex] {$b=2$};
                    draw (5,2.75) node[right=1ex] {$b=1$};
                    draw (-0.5,0) node (n) {$N$};
                    draw (-0.5,2.25) node (m) {$M$};
                    draw[-latex] (m)--(n) node[midway,left] {$f$};
                    end{tikzpicture}
                    end{document}


                    enter image description here






                    share|improve this answer


























                      9












                      9








                      9







                      I think Bézier curves can do the task. It can make sure that the starting points and the ending points of all curves are placed with a consistent ratio.



                      documentclass[tikz]{standalone}
                      definnersep{.5em}
                      usetikzlibrary{patterns}
                      begin{document}
                      begin{tikzpicture}[y=baselineskip+2*innersep]
                      draw (0,0)--(6.5,0);
                      draw (0,1.5)--(6.5,1.5);
                      draw (0,1)--(4.75,1) .. controls (4.9,1) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,1) .. (5.25,1)--(6.5,1);
                      draw (0,2)--(1.25,2) .. controls (1.4,2) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2) .. (1.75,2)--(4.75,2) .. controls (4.9,2) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,2) .. (5.25,2)--(6.5,2);
                      draw (0,2.5)--(1.25,2.5) .. controls (1.4,2.5) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2.5) .. (1.75,2.5)--(4.75,2.5) .. controls (4.9,2.5) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,2.5) .. (5.25,2.5)--(6.5,2.5);
                      draw (0,3)--(4.75,3) .. controls (4.9,3) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,3) .. (5.25,3)--(6.5,3);
                      fill (1.5,2.25) circle (1.5pt) (5,1.5) circle (1.5pt) (5,2.75) circle (1.5pt) (1.5,0) circle (1.5pt) (5,0) circle (1.5pt);
                      draw[dashed] (1.5,0)--(1.5,3.25) (5,0)--(5,3.25);
                      draw (1.5,2.25) node[right=1ex] {$b=1$};
                      draw (5,1.75) node[right=1ex] {$b=2$};
                      draw (5,2.75) node[right=1ex] {$b=1$};
                      draw (-0.5,0) node (n) {$N$};
                      draw (-0.5,2.25) node (m) {$M$};
                      draw[-latex] (m)--(n) node[midway,left] {$f$};
                      end{tikzpicture}
                      end{document}


                      enter image description here






                      share|improve this answer













                      I think Bézier curves can do the task. It can make sure that the starting points and the ending points of all curves are placed with a consistent ratio.



                      documentclass[tikz]{standalone}
                      definnersep{.5em}
                      usetikzlibrary{patterns}
                      begin{document}
                      begin{tikzpicture}[y=baselineskip+2*innersep]
                      draw (0,0)--(6.5,0);
                      draw (0,1.5)--(6.5,1.5);
                      draw (0,1)--(4.75,1) .. controls (4.9,1) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,1) .. (5.25,1)--(6.5,1);
                      draw (0,2)--(1.25,2) .. controls (1.4,2) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2) .. (1.75,2)--(4.75,2) .. controls (4.9,2) and (4.85,1.5) .. (5,1.5) .. controls (5.15,1.5) and (5.1,2) .. (5.25,2)--(6.5,2);
                      draw (0,2.5)--(1.25,2.5) .. controls (1.4,2.5) and (1.35,2.25) .. (1.5,2.25) .. controls (1.65,2.25) and (1.6,2.5) .. (1.75,2.5)--(4.75,2.5) .. controls (4.9,2.5) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,2.5) .. (5.25,2.5)--(6.5,2.5);
                      draw (0,3)--(4.75,3) .. controls (4.9,3) and (4.85,2.75) .. (5,2.75) .. controls (5.15,2.75) and (5.1,3) .. (5.25,3)--(6.5,3);
                      fill (1.5,2.25) circle (1.5pt) (5,1.5) circle (1.5pt) (5,2.75) circle (1.5pt) (1.5,0) circle (1.5pt) (5,0) circle (1.5pt);
                      draw[dashed] (1.5,0)--(1.5,3.25) (5,0)--(5,3.25);
                      draw (1.5,2.25) node[right=1ex] {$b=1$};
                      draw (5,1.75) node[right=1ex] {$b=2$};
                      draw (5,2.75) node[right=1ex] {$b=1$};
                      draw (-0.5,0) node (n) {$N$};
                      draw (-0.5,2.25) node (m) {$M$};
                      draw[-latex] (m)--(n) node[midway,left] {$f$};
                      end{tikzpicture}
                      end{document}


                      enter image description here







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered yesterday









                      JouleVJouleV

                      7,89222053




                      7,89222053























                          6














                          This is a proof of concept how to use plot[smooth] coordinates to do this.



                          documentclass[tikz,border=7pt]{standalone}
                          begin{document}
                          begin{tikzpicture}[yscale=.5,
                          sheet/.style={red,thick,smooth},
                          point/.style={insert path={node[scale=4]{.}}}]
                          % ---- sheets ----
                          foreach[count=i] pts in {
                          {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7,-1) (8, 0) (9, 0)},%
                          {(0, 0) (1, 0) (2,-1) (3, 0) (6, 0) (7, 1) (8, 0) (9, 0)},%
                          {(0, 0) (1, 0) (2, 1) (3, 0) (6, 0) (7,-2) (8, 0) (9, 0)},%
                          {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 0) (8, 0) (9, 0)},%
                          {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 2) (8, 0) (9, 0)},%
                          {(0,0)},%
                          {(0, 0) (9, 0)}%
                          }{
                          draw[yshift=-2*i cm,sheet] plot coordinates {pts};
                          }
                          % ---- singular points and labels ----
                          path
                          (2,-5) [point] (3,-5) node{$b=1$}
                          (7,-3) [point] (8,-3) node{$b=1$}
                          (7,-8) [point] (8,-7.5) node{$b=2$}
                          ;
                          % ---- vertical lines ----
                          draw[dashed]
                          (2,0) -- +(0,-14) [point]
                          (7,0) -- +(0,-14) [point]
                          ;
                          end{tikzpicture}
                          end{document}


                          enter image description here






                          share|improve this answer




























                            6














                            This is a proof of concept how to use plot[smooth] coordinates to do this.



                            documentclass[tikz,border=7pt]{standalone}
                            begin{document}
                            begin{tikzpicture}[yscale=.5,
                            sheet/.style={red,thick,smooth},
                            point/.style={insert path={node[scale=4]{.}}}]
                            % ---- sheets ----
                            foreach[count=i] pts in {
                            {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7,-1) (8, 0) (9, 0)},%
                            {(0, 0) (1, 0) (2,-1) (3, 0) (6, 0) (7, 1) (8, 0) (9, 0)},%
                            {(0, 0) (1, 0) (2, 1) (3, 0) (6, 0) (7,-2) (8, 0) (9, 0)},%
                            {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 0) (8, 0) (9, 0)},%
                            {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 2) (8, 0) (9, 0)},%
                            {(0,0)},%
                            {(0, 0) (9, 0)}%
                            }{
                            draw[yshift=-2*i cm,sheet] plot coordinates {pts};
                            }
                            % ---- singular points and labels ----
                            path
                            (2,-5) [point] (3,-5) node{$b=1$}
                            (7,-3) [point] (8,-3) node{$b=1$}
                            (7,-8) [point] (8,-7.5) node{$b=2$}
                            ;
                            % ---- vertical lines ----
                            draw[dashed]
                            (2,0) -- +(0,-14) [point]
                            (7,0) -- +(0,-14) [point]
                            ;
                            end{tikzpicture}
                            end{document}


                            enter image description here






                            share|improve this answer


























                              6












                              6








                              6







                              This is a proof of concept how to use plot[smooth] coordinates to do this.



                              documentclass[tikz,border=7pt]{standalone}
                              begin{document}
                              begin{tikzpicture}[yscale=.5,
                              sheet/.style={red,thick,smooth},
                              point/.style={insert path={node[scale=4]{.}}}]
                              % ---- sheets ----
                              foreach[count=i] pts in {
                              {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7,-1) (8, 0) (9, 0)},%
                              {(0, 0) (1, 0) (2,-1) (3, 0) (6, 0) (7, 1) (8, 0) (9, 0)},%
                              {(0, 0) (1, 0) (2, 1) (3, 0) (6, 0) (7,-2) (8, 0) (9, 0)},%
                              {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 0) (8, 0) (9, 0)},%
                              {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 2) (8, 0) (9, 0)},%
                              {(0,0)},%
                              {(0, 0) (9, 0)}%
                              }{
                              draw[yshift=-2*i cm,sheet] plot coordinates {pts};
                              }
                              % ---- singular points and labels ----
                              path
                              (2,-5) [point] (3,-5) node{$b=1$}
                              (7,-3) [point] (8,-3) node{$b=1$}
                              (7,-8) [point] (8,-7.5) node{$b=2$}
                              ;
                              % ---- vertical lines ----
                              draw[dashed]
                              (2,0) -- +(0,-14) [point]
                              (7,0) -- +(0,-14) [point]
                              ;
                              end{tikzpicture}
                              end{document}


                              enter image description here






                              share|improve this answer













                              This is a proof of concept how to use plot[smooth] coordinates to do this.



                              documentclass[tikz,border=7pt]{standalone}
                              begin{document}
                              begin{tikzpicture}[yscale=.5,
                              sheet/.style={red,thick,smooth},
                              point/.style={insert path={node[scale=4]{.}}}]
                              % ---- sheets ----
                              foreach[count=i] pts in {
                              {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7,-1) (8, 0) (9, 0)},%
                              {(0, 0) (1, 0) (2,-1) (3, 0) (6, 0) (7, 1) (8, 0) (9, 0)},%
                              {(0, 0) (1, 0) (2, 1) (3, 0) (6, 0) (7,-2) (8, 0) (9, 0)},%
                              {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 0) (8, 0) (9, 0)},%
                              {(0, 0) (1, 0) (2, 0) (3, 0) (6, 0) (7, 2) (8, 0) (9, 0)},%
                              {(0,0)},%
                              {(0, 0) (9, 0)}%
                              }{
                              draw[yshift=-2*i cm,sheet] plot coordinates {pts};
                              }
                              % ---- singular points and labels ----
                              path
                              (2,-5) [point] (3,-5) node{$b=1$}
                              (7,-3) [point] (8,-3) node{$b=1$}
                              (7,-8) [point] (8,-7.5) node{$b=2$}
                              ;
                              % ---- vertical lines ----
                              draw[dashed]
                              (2,0) -- +(0,-14) [point]
                              (7,0) -- +(0,-14) [point]
                              ;
                              end{tikzpicture}
                              end{document}


                              enter image description here







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered yesterday









                              KpymKpym

                              17k24090




                              17k24090























                                  5














                                  This is a proof of concept how to use turtle library to define the following "moves" :





                                  • up make an up bump


                                  • up* make an up bump with (red) dot


                                  • dn make a down bump


                                  • dn* make a down bump with (red) dot


                                  • * put a (red) dot


                                  documentclass[tikz,border=7pt]{standalone}
                                  usetikzlibrary{turtle}
                                  tikzset{
                                  turtle/.cd,
                                  how/.style={out=0,in=180},
                                  home/.append style=right,
                                  */.style={/tikz/insert path={node[red,scale=4]{.}}},
                                  forward/.default=1.4142135,
                                  up/.style={left=45,forward,right,forward,left=45},
                                  up*/.style={left=45,forward,*,right,forward,left=45},
                                  dn/.style={right=45,forward,left,forward,right=45},
                                  dn*/.style={right=45,forward,*,left,forward,right=45},
                                  next/.style={/tikz/yshift=-1cm}
                                  }

                                  begin{document}
                                  tikz
                                  draw[thick]
                                  [turtle={home,fd,fd,fd,fd,fd,fd,dn,fd},next,next]
                                  [turtle={home,fd,fd,dn,fd,fd,up*,fd},next,next]
                                  [turtle={home,fd,fd,up*,fd,fd,dn,fd},next]
                                  [turtle={home,fd,fd,fd,fd,fd,fd,fd,fd,fd},next]
                                  [turtle={home,fd,fd,fd,fd,fd,fd,up*,fd}]
                                  ;
                                  end{document}


                                  enter image description here






                                  share|improve this answer




























                                    5














                                    This is a proof of concept how to use turtle library to define the following "moves" :





                                    • up make an up bump


                                    • up* make an up bump with (red) dot


                                    • dn make a down bump


                                    • dn* make a down bump with (red) dot


                                    • * put a (red) dot


                                    documentclass[tikz,border=7pt]{standalone}
                                    usetikzlibrary{turtle}
                                    tikzset{
                                    turtle/.cd,
                                    how/.style={out=0,in=180},
                                    home/.append style=right,
                                    */.style={/tikz/insert path={node[red,scale=4]{.}}},
                                    forward/.default=1.4142135,
                                    up/.style={left=45,forward,right,forward,left=45},
                                    up*/.style={left=45,forward,*,right,forward,left=45},
                                    dn/.style={right=45,forward,left,forward,right=45},
                                    dn*/.style={right=45,forward,*,left,forward,right=45},
                                    next/.style={/tikz/yshift=-1cm}
                                    }

                                    begin{document}
                                    tikz
                                    draw[thick]
                                    [turtle={home,fd,fd,fd,fd,fd,fd,dn,fd},next,next]
                                    [turtle={home,fd,fd,dn,fd,fd,up*,fd},next,next]
                                    [turtle={home,fd,fd,up*,fd,fd,dn,fd},next]
                                    [turtle={home,fd,fd,fd,fd,fd,fd,fd,fd,fd},next]
                                    [turtle={home,fd,fd,fd,fd,fd,fd,up*,fd}]
                                    ;
                                    end{document}


                                    enter image description here






                                    share|improve this answer


























                                      5












                                      5








                                      5







                                      This is a proof of concept how to use turtle library to define the following "moves" :





                                      • up make an up bump


                                      • up* make an up bump with (red) dot


                                      • dn make a down bump


                                      • dn* make a down bump with (red) dot


                                      • * put a (red) dot


                                      documentclass[tikz,border=7pt]{standalone}
                                      usetikzlibrary{turtle}
                                      tikzset{
                                      turtle/.cd,
                                      how/.style={out=0,in=180},
                                      home/.append style=right,
                                      */.style={/tikz/insert path={node[red,scale=4]{.}}},
                                      forward/.default=1.4142135,
                                      up/.style={left=45,forward,right,forward,left=45},
                                      up*/.style={left=45,forward,*,right,forward,left=45},
                                      dn/.style={right=45,forward,left,forward,right=45},
                                      dn*/.style={right=45,forward,*,left,forward,right=45},
                                      next/.style={/tikz/yshift=-1cm}
                                      }

                                      begin{document}
                                      tikz
                                      draw[thick]
                                      [turtle={home,fd,fd,fd,fd,fd,fd,dn,fd},next,next]
                                      [turtle={home,fd,fd,dn,fd,fd,up*,fd},next,next]
                                      [turtle={home,fd,fd,up*,fd,fd,dn,fd},next]
                                      [turtle={home,fd,fd,fd,fd,fd,fd,fd,fd,fd},next]
                                      [turtle={home,fd,fd,fd,fd,fd,fd,up*,fd}]
                                      ;
                                      end{document}


                                      enter image description here






                                      share|improve this answer













                                      This is a proof of concept how to use turtle library to define the following "moves" :





                                      • up make an up bump


                                      • up* make an up bump with (red) dot


                                      • dn make a down bump


                                      • dn* make a down bump with (red) dot


                                      • * put a (red) dot


                                      documentclass[tikz,border=7pt]{standalone}
                                      usetikzlibrary{turtle}
                                      tikzset{
                                      turtle/.cd,
                                      how/.style={out=0,in=180},
                                      home/.append style=right,
                                      */.style={/tikz/insert path={node[red,scale=4]{.}}},
                                      forward/.default=1.4142135,
                                      up/.style={left=45,forward,right,forward,left=45},
                                      up*/.style={left=45,forward,*,right,forward,left=45},
                                      dn/.style={right=45,forward,left,forward,right=45},
                                      dn*/.style={right=45,forward,*,left,forward,right=45},
                                      next/.style={/tikz/yshift=-1cm}
                                      }

                                      begin{document}
                                      tikz
                                      draw[thick]
                                      [turtle={home,fd,fd,fd,fd,fd,fd,dn,fd},next,next]
                                      [turtle={home,fd,fd,dn,fd,fd,up*,fd},next,next]
                                      [turtle={home,fd,fd,up*,fd,fd,dn,fd},next]
                                      [turtle={home,fd,fd,fd,fd,fd,fd,fd,fd,fd},next]
                                      [turtle={home,fd,fd,fd,fd,fd,fd,up*,fd}]
                                      ;
                                      end{document}


                                      enter image description here







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered yesterday









                                      KpymKpym

                                      17k24090




                                      17k24090























                                          5














                                          Edit notes:




                                          • spaces can now be handled, but are ignored by default


                                          • alternative syntax for myparserdef added





                                          Inspired by Kpym's answer but thinking that the possibilities of pgfparser are insufficient, I wrote my own parser, that should be similar to pgf's, but allows the parsed elements to grab arguments. The following arguments are supported:





                                          • m a mandatory argument


                                          • r{<delim>} a mandatory argument delimited by <delim>


                                          • o an optional argument in brackets (you can test for it with myIfNoValueTF)


                                          • O{<default>} an optional argument defaulting to <default>


                                          • d<delim1><delim2> an optional argument delimited by <delim1> and <delim2> (you can test for it with myIfNoValueTF)


                                          • D<delim1><delim2>{<default>} an optional argument delimited by <delim1> and <delim2> defaulting to <default>


                                          • t<token> an optional token (you can test for it with myIfBooleanTF)


                                          Despite the fact that the argument names are inspired by xparse, none of them care for balanced delimiters (e.g., [[ab]] would not be grabbed as [ab], but as [ab with an orphaned ], so you'd have to use [{[ab]}], this is like the LaTeX2e behaviour). Also all arguments are long by nature unlike xparse where you'd need to specify that using +.



                                          You can define a parser using myparserdef{<name>}{<state>}{<meaning>}[<args>]{<code>}, with <name> the name of the parser, <state> the state, <meaning> the meaning of a token, <args> an argument string (built from the arguments listed above, up to 9 arguments are supported) and <code> the code which should be executed for that combination of <name>, <state> and <meaning>. You can switch states using myparserstate{<state>}, if you switch to final parsing is ended, the initial state is initial. All in all this is pretty similar to pgfparsers way of doing things. The biggest difference is, that my parser ignores blanks by default, however you can define an action for blanks with myparserdef{<name>}{<state>}{blank space}[<args>]{<code>}. Many consecutive blanks are considered as one.



                                          You can also use a different syntax for myparserdef namely: myparserdef{<name>}{<state>}<token>[<args>]{<code>} with <token> being a single token not surrounded by {} (spaces are ignored here, it is not checked whether <token> is really a single token, so be careful). In that case the same will be done as if you'd typed the meaning of the <token>, so myparserdef{foo}{bar}a{baz} does the same as myparserdef{foo}{bar}{the letter a}{baz}.



                                          A parser is executed using myparserrun{<name>}. A parser needs at least one rule, else an error is thrown.



                                          This parser system allows me to place coordinates inside of sheet, which was the main reason why I found pgfparser insufficient.



                                          I did all of this without using any packages, only LaTeX-Kernel macros, just for procrastinating reasons. Using for example xparse would shorten the code considerably.



                                          documentclass[tikz,border=7pt]{standalone}

                                          % my parser >>>
                                          makeatletter
                                          % logic helpers >>>
                                          longdefmyfi@An#1fi#2{fi}
                                          longdefmyfi@Ay#1fi#2{fi#2}
                                          longdefmyfi@Byfi#1{fi#1}
                                          longdefmyfi@BTbfi#1#2#3{fi#2}
                                          % <<<
                                          % mynewdef >>>
                                          @ifdefinablemyifundefTF%>>>
                                          {%
                                          defmyifundefTF#1%
                                          {%
                                          ifdefined#1%
                                          myfi@Ay
                                          else
                                          myfi@BTb
                                          fi
                                          {%
                                          ifx#1relax
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%
                                          }%
                                          }%<<<
                                          @ifdefinablemynewdef%>>>
                                          {%
                                          protecteddefmynewdef{@ifnextchar[{mynewdef@a}{mynewdef@a}}%
                                          }%<<<
                                          @ifdefinablemynewdef@a%>>>
                                          {%
                                          longdefmynewdef@a[#1]#2#3#{mynewdef@b{#1}#2{#3}}%
                                          }%<<<
                                          @ifdefinablemynewdef@b%>>>
                                          {%
                                          protectedlongdefmynewdef@b#1#2#3#4%
                                          {%
                                          myifundefTF#2%
                                          {%
                                          #1def#2#3{#4}%
                                          }
                                          {%
                                          PackageError{my}{Command string#2space already defined}{}%
                                          }
                                          }%
                                          }%<<<
                                          mynewdefmyifcsundefTF#1%>>>
                                          {%
                                          ifcsname #1endcsname
                                          myfi@Ay
                                          else
                                          myfi@BTb
                                          fi
                                          {%
                                          expandafterifxcsname #1endcsnamerelax
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%
                                          }%<<<
                                          % <<<
                                          % opt arg parsing >>>
                                          mynewdef[long]my@ifmark#1%>>>
                                          {%
                                          ifxmy@mark#1%
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@oarg#1%>>>
                                          {%
                                          @ifnextchar[{myoarg@oarg@{#1}}{#1{my@mark}}%
                                          }%<<<
                                          mynewdef[long]myoarg@oarg@#1[#2]%>>>
                                          {%
                                          #1{#2}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@Oarg#1#2%>>>
                                          {%
                                          @ifnextchar[{myoarg@oarg@{#2}}{#2{#1}}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@darg#1#2#3%>>>
                                          {%
                                          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
                                          @ifnextchar#1{myoarg@darg@{#3}}{#3{my@mark}}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@Darg#1#2#3#4%>>>
                                          {%
                                          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
                                          @ifnextchar#1{myoarg@darg@{#4}}{#4{#3}}%
                                          }%<<<
                                          % <<<
                                          % macros for string comparison >>>
                                          begingroupdef:{endgroupletmy@sptoken= }:
                                          mynewdefmy@mark{my@mark@if@you@see@this@report@it}
                                          mynewdefmy@stop{my@stop@if@you@see@this@report@it}
                                          mynewdefmyparser@final{final}
                                          mynewdefmyparser@noarg{noarg}
                                          mynewdefmyparser@blankspace{blank space}
                                          % <<<
                                          mynewdef[protected]myparserdef#1#2%>>>
                                          {%
                                          defmyparserdef@twoargs{{#1}{#2}}%
                                          myparserdef@a
                                          }%<<<
                                          mynewdef[protected]myparserdef@a%>>>
                                          {%
                                          futureletmyparserdef@argmyparserdef@b
                                          }%<<<
                                          mynewdefmyparserdef@b%>>>
                                          {%
                                          ifxmyparserdef@argmy@sptoken
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {myparserdef@gobble@space}
                                          {myparserdef@c}%
                                          }%<<<
                                          mynewdef[protected]myparserdef@gobble@space%>>>
                                          {%
                                          afterassignmentmyparserdef@a
                                          letmyparserdef@arg= % space after = to get spaces, too
                                          }%<<<
                                          mynewdef[protected]myparserdef@c#1%>>>
                                          {%
                                          ifxmyparserdef@argbgroup
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {%
                                          defmyparserdef@arg{#1}%
                                          ifxmyparser@blankspacemyparserdef@arg
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {expandaftermyparserdef@dmyparserdef@twoargs{blank space space}}
                                          {expandaftermyparserdef@dmyparserdef@twoargs{#1}}%
                                          }
                                          {expandaftermyparserdef@dmyparserdef@twoargs{meaningmyparserdef@arg}}%
                                          }%<<<
                                          mynewdef[long]myparserdef@d#1#2#3%>>>
                                          {%
                                          myoarg@oarg{myparserdef@e{#1}{#2}{#3}}%
                                          }%<<<
                                          mynewdef[protectedlong]myparserdef@e#1#2#3#4#5%>>>
                                          {%
                                          % if that is the first rule for the parser, define space to be a no-op
                                          myifcsundefTF{myparser@name{#1}}%
                                          {%
                                          expandafterdef
                                          csname myparser@name{#1} all blank space spacespace typeendcsname
                                          {noarg}%
                                          expandafterdef
                                          csname myparser@name{#1} all blank space spacespace codeendcsname
                                          {myparser@getnexttoken}%
                                          % use a macro as a flag that there is at least one parser rule defined
                                          expandafterdefcsnamemyparser@name{#1}endcsname{}%
                                          }
                                          {}%
                                          % check whether the optional argument was used
                                          my@ifmark{#4}
                                          {%
                                          % use a macro as flag that there is a rule for the specified state
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{noarg}%
                                          defmyparserdef@arg@count{0}%
                                          }
                                          {%
                                          edefmyparserdef@arg@count
                                          {thenumexprmyparserdef@argcount#4my@mark}%
                                          ifnummyparserdef@arg@count>9%
                                          PackageError{my}{Too many arguments for parser rule}
                                          {A maximum of 9 parameters is supported.}%
                                          else
                                          ifnummyparserdef@arg@count=0%
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname
                                          {noarg}%
                                          else
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{#4}%
                                          fi
                                          fi
                                          }%
                                          % define what the code does
                                          expandafterdefcsname myparser@name{#1} #2 #3 codeendcsname{}%
                                          expandafterrenewcommandcsname myparser@name{#1} #2 #3 codeendcsname
                                          [myparserdef@arg@count]{#5myparser@getnexttoken}%
                                          }%<<<
                                          mynewdefmyparserdef@argcount#1%>>>
                                          {%
                                          ifxmy@mark#1%
                                          myfi@An
                                          else
                                          myfi@By
                                          fi
                                          {csname myparserdef@argcount@#1endcsname}%
                                          }%<<<
                                          mynewdefmyparserdef@argcount@m%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@o%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@O#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@d#1#2%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@D#1#2#3%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@r#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@t#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparser@name#1%>>>
                                          {%
                                          myparser #1%
                                          }%<<<
                                          mynewdefmyparser@rule#1%>>>
                                          {%
                                          myparser@currentspace #1space meaningmyparser@token
                                          }%<<<
                                          mynewdefmyparser@type#1%>>>
                                          {%
                                          myparser@rule{#1} type%
                                          }%<<<
                                          mynewdefmyparser@code#1%>>>
                                          {%
                                          myparser@rule{#1} code%
                                          }%<<<
                                          mynewdef[protected]myparserrun#1%>>>
                                          {%
                                          myifcsundefTF{myparser@name{#1}}
                                          {PackageError{my}{No parser named '#1' defined}{}}
                                          {%
                                          edefmyparser@current{myparser@name{#1}}%
                                          defmyparser@usersname{#1}%
                                          defmyparser@state{initial}%
                                          myparser@getnexttoken
                                          }%
                                          }%<<<
                                          mynewdef[protected]myparser@getnexttoken%>>>
                                          {%
                                          ifxmyparser@statemyparser@final
                                          myfi@An
                                          else
                                          myfi@By
                                          fi
                                          {%
                                          afterassignmentmyparser@getnexttoken@a
                                          letmyparser@token= % space after = to get spaces, too
                                          }%
                                          }%<<<
                                          mynewdef[protected]myparser@getnexttoken@a%>>>
                                          {%
                                          myifcsundefTF{myparser@type{myparser@state}}
                                          {%
                                          myifcsundefTF{myparser@type{all}}
                                          {%
                                          PackageError{my}
                                          {%
                                          No rule for parser 'myparser@usersname' in state
                                          'myparser@state' for 'meaningmyparser@token'.
                                          Ignoring token%
                                          }
                                          {}%
                                          myparser@getnexttoken
                                          }
                                          {myparser@handle{all}}%
                                          }
                                          {myparser@handle{myparser@state}}%
                                          }%<<<
                                          mynewdef[protected]myparser@handle#1%>>>
                                          {%
                                          expandafterifxcsnamemyparser@type{#1}endcsnamemyparser@noarg
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {csnamemyparser@code{#1}endcsname}
                                          {myparser@handle@args{#1}}%
                                          }%<<<
                                          mynewdef[protected]myparserstate#1%>>>
                                          {%
                                          defmyparser@state{#1}%
                                          }%<<<
                                          mynewdef[protected]myparser@handle@args#1%>>>
                                          {%
                                          defmyparser@stateorall{#1}%
                                          expandafterexpandafterexpandaftermyparser@handle@args@a
                                          csnamemyparser@type{#1}endcsnamemy@markmy@stop
                                          }%<<<
                                          mynewdefmyparser@handle@args@a%>>>
                                          {%
                                          myparser@handle@args@b{}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@b#1#2#3my@stop%>>>
                                          {%
                                          my@ifmark{#2}
                                          {csnamemyparser@code{myparser@stateorall}endcsname#1}
                                          {%
                                          myifcsundefTF{myparser@handle@args@#2}
                                          {PackageError{my}{Unknown argument type '#2'}{}}
                                          {csname myparser@handle@args@#2endcsname{#1}{#3}}%
                                          }%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@c#1#2%>>>
                                          {%
                                          my@ifmark{#2}
                                          {csnamemyparser@code{myparser@stateorall}endcsname#1}
                                          {myparser@handle@args@b{#1}#2my@stop}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@m#1#2#3%>>>
                                          {%
                                          myparser@handle@args@c{#1{#3}}{#2}%
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@o#1#2%>>>
                                          {%
                                          myoarg@oarg{myparser@handle@args@m{#1}{#2}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@O#1#2%>>>
                                          {%
                                          myparser@handle@args@O@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@O@#1#2#3my@stop%>>>
                                          {%
                                          myoarg@Oarg{#2}{myparser@handle@args@m{#1}{#3}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@d#1#2%>>>
                                          {%
                                          myparser@handle@args@d@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@d@#1#2#3#4my@stop%>>>
                                          {%
                                          myoarg@darg{#2}{#3}{myparser@handle@args@m{#1}{#4}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@D#1#2%>>>
                                          {%
                                          myparser@handle@args@D@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@D@#1#2#3#4#5my@stop%>>>
                                          {%
                                          myoarg@Darg{#2}{#3}{#4}{myparser@handle@args@m{#1}{#5}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@r#1#2%>>>
                                          {%
                                          myparser@handle@args@r@a{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@r@a#1#2#3my@stop%>>>
                                          {%
                                          defmyparser@handle@args@r@b##1#2{myparser@handle@args@c{#1{##1}}{#3}}%
                                          myparser@handle@args@r@b
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@t#1#2%>>>
                                          {%
                                          myparser@handle@args@t@a{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@t@a#1#2#3my@stop%>>>
                                          {%
                                          @ifnextchar#2%
                                          {@firstoftwo{myparser@handle@args@c{#1{my@mark}}{#3}}}
                                          {myparser@handle@args@c{#1{my@stop}}{#3}}%
                                          }%<<<
                                          letmyIfNoValueTFmy@ifmark
                                          letmyIfBooleanTFmy@ifmark
                                          makeatother
                                          % <<<

                                          % the sheet path parser >>>
                                          makeatletter
                                          definsertpath#1{edefsheetpath@{unexpandedexpandafter{sheetpath@#1}}}
                                          defsheetpathcurve#1#2#3#4%
                                          {%
                                          to[out=0,in=180] ++({.5*sheetlength},{#1*sheetheight})
                                          myIfBooleanTF{#3}{}{node[scale=sheetdotsize,inner sep=0pt]{.}}
                                          myIfNoValueTF{#4}{}{coordinate({#4})}
                                          to[out=0,in=180] ++({.5*sheetlength},{#2*sheetheight})
                                          }
                                          defoutputpath{drawsheetpath@;}
                                          defsheet{defsheetpath@{}myparserrun{sheet path}}
                                          makeatother
                                          myparserdef{sheet path}{initial}{the character (}[r,r)]
                                          {insertpath{({#1},{#2*sheetheight})}myparserstate{started}}
                                          myparserdef{sheet path}{initial}{the character =}
                                          {insertpath{(0,0)--++(sheetlength,0)}myparserstate{started}}
                                          myparserdef{sheet path}{started}{the character (}[r)]
                                          {insertpath{coordinate({#1})}}
                                          myparserdef{sheet path}{started}{the character =}
                                          {insertpath{--++(sheetlength,0)}}
                                          myparserdef{sheet path}{started}{the letter u}[txd()]
                                          {insertpath{sheetpathcurve{.5}{-.5}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter U}[txd()]
                                          {insertpath{sheetpathcurve{1}{-1}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter d}[txd()]
                                          {insertpath{sheetpathcurve{-.5}{.5}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter D}[txd()]
                                          {insertpath{sheetpathcurve{-1}{1}{#1}{#2}}}
                                          % making '.' a no-op, that way we can use it to end the search for an optional
                                          % argument for instance
                                          myparserdef{sheet path}{started} .{}
                                          myparserdef{sheet path}{started}{the letter x}[d()]
                                          {%
                                          myIfNoValueTF{#1}
                                          {%
                                          insertpath
                                          {--node[scale=sheetdotsize,inner sep=0pt]{.}++(sheetlength,0)}%
                                          }
                                          {%
                                          insertpath
                                          {%
                                          --node[scale=sheetdotsize,inner sep=0pt]{.}
                                          coordinate({#1})
                                          ++(sheetlength,0)
                                          }%
                                          }%
                                          }
                                          myparserdef{sheet path}{all}{the character ;}{myparserstate{final}outputpath}
                                          % <<<

                                          % sheet height and sheet length >>>
                                          pgfset
                                          {
                                          ,sheet height/.store in=sheetheight
                                          ,sheet height=1
                                          ,sheet length/.store in=sheetlength
                                          ,sheet length=1
                                          ,sheet dot size/.store in=sheetdotsize
                                          ,sheet dot size=4
                                          }
                                          %<<<

                                          begin{document}
                                          begin{tikzpicture}
                                          begin{scope}[thick, sheet height=0.75]
                                          sheet === ===d(sp1)=;
                                          sheet (0,-1) ==d(sp2)===ux =;
                                          sheet (0,-2) ==ux ===Dx =;
                                          sheet (0,-3) === ==== =;
                                          sheet (0,-4) === ===U(sp3)=;
                                          sheet (0,-5.5) ==x(b1) ===x(b2) =;
                                          end{scope}
                                          draw[dashed]
                                          (b2) -- (sp1)
                                          (b1) -- (sp2)
                                          ;
                                          end{tikzpicture}
                                          end{document}


                                          enter image description here






                                          share|improve this answer


























                                          • Wow ! This is a huge work. I'm impressed (like always I'm by the texperts ;)).

                                            – Kpym
                                            4 hours ago
















                                          5














                                          Edit notes:




                                          • spaces can now be handled, but are ignored by default


                                          • alternative syntax for myparserdef added





                                          Inspired by Kpym's answer but thinking that the possibilities of pgfparser are insufficient, I wrote my own parser, that should be similar to pgf's, but allows the parsed elements to grab arguments. The following arguments are supported:





                                          • m a mandatory argument


                                          • r{<delim>} a mandatory argument delimited by <delim>


                                          • o an optional argument in brackets (you can test for it with myIfNoValueTF)


                                          • O{<default>} an optional argument defaulting to <default>


                                          • d<delim1><delim2> an optional argument delimited by <delim1> and <delim2> (you can test for it with myIfNoValueTF)


                                          • D<delim1><delim2>{<default>} an optional argument delimited by <delim1> and <delim2> defaulting to <default>


                                          • t<token> an optional token (you can test for it with myIfBooleanTF)


                                          Despite the fact that the argument names are inspired by xparse, none of them care for balanced delimiters (e.g., [[ab]] would not be grabbed as [ab], but as [ab with an orphaned ], so you'd have to use [{[ab]}], this is like the LaTeX2e behaviour). Also all arguments are long by nature unlike xparse where you'd need to specify that using +.



                                          You can define a parser using myparserdef{<name>}{<state>}{<meaning>}[<args>]{<code>}, with <name> the name of the parser, <state> the state, <meaning> the meaning of a token, <args> an argument string (built from the arguments listed above, up to 9 arguments are supported) and <code> the code which should be executed for that combination of <name>, <state> and <meaning>. You can switch states using myparserstate{<state>}, if you switch to final parsing is ended, the initial state is initial. All in all this is pretty similar to pgfparsers way of doing things. The biggest difference is, that my parser ignores blanks by default, however you can define an action for blanks with myparserdef{<name>}{<state>}{blank space}[<args>]{<code>}. Many consecutive blanks are considered as one.



                                          You can also use a different syntax for myparserdef namely: myparserdef{<name>}{<state>}<token>[<args>]{<code>} with <token> being a single token not surrounded by {} (spaces are ignored here, it is not checked whether <token> is really a single token, so be careful). In that case the same will be done as if you'd typed the meaning of the <token>, so myparserdef{foo}{bar}a{baz} does the same as myparserdef{foo}{bar}{the letter a}{baz}.



                                          A parser is executed using myparserrun{<name>}. A parser needs at least one rule, else an error is thrown.



                                          This parser system allows me to place coordinates inside of sheet, which was the main reason why I found pgfparser insufficient.



                                          I did all of this without using any packages, only LaTeX-Kernel macros, just for procrastinating reasons. Using for example xparse would shorten the code considerably.



                                          documentclass[tikz,border=7pt]{standalone}

                                          % my parser >>>
                                          makeatletter
                                          % logic helpers >>>
                                          longdefmyfi@An#1fi#2{fi}
                                          longdefmyfi@Ay#1fi#2{fi#2}
                                          longdefmyfi@Byfi#1{fi#1}
                                          longdefmyfi@BTbfi#1#2#3{fi#2}
                                          % <<<
                                          % mynewdef >>>
                                          @ifdefinablemyifundefTF%>>>
                                          {%
                                          defmyifundefTF#1%
                                          {%
                                          ifdefined#1%
                                          myfi@Ay
                                          else
                                          myfi@BTb
                                          fi
                                          {%
                                          ifx#1relax
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%
                                          }%
                                          }%<<<
                                          @ifdefinablemynewdef%>>>
                                          {%
                                          protecteddefmynewdef{@ifnextchar[{mynewdef@a}{mynewdef@a}}%
                                          }%<<<
                                          @ifdefinablemynewdef@a%>>>
                                          {%
                                          longdefmynewdef@a[#1]#2#3#{mynewdef@b{#1}#2{#3}}%
                                          }%<<<
                                          @ifdefinablemynewdef@b%>>>
                                          {%
                                          protectedlongdefmynewdef@b#1#2#3#4%
                                          {%
                                          myifundefTF#2%
                                          {%
                                          #1def#2#3{#4}%
                                          }
                                          {%
                                          PackageError{my}{Command string#2space already defined}{}%
                                          }
                                          }%
                                          }%<<<
                                          mynewdefmyifcsundefTF#1%>>>
                                          {%
                                          ifcsname #1endcsname
                                          myfi@Ay
                                          else
                                          myfi@BTb
                                          fi
                                          {%
                                          expandafterifxcsname #1endcsnamerelax
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%
                                          }%<<<
                                          % <<<
                                          % opt arg parsing >>>
                                          mynewdef[long]my@ifmark#1%>>>
                                          {%
                                          ifxmy@mark#1%
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@oarg#1%>>>
                                          {%
                                          @ifnextchar[{myoarg@oarg@{#1}}{#1{my@mark}}%
                                          }%<<<
                                          mynewdef[long]myoarg@oarg@#1[#2]%>>>
                                          {%
                                          #1{#2}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@Oarg#1#2%>>>
                                          {%
                                          @ifnextchar[{myoarg@oarg@{#2}}{#2{#1}}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@darg#1#2#3%>>>
                                          {%
                                          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
                                          @ifnextchar#1{myoarg@darg@{#3}}{#3{my@mark}}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@Darg#1#2#3#4%>>>
                                          {%
                                          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
                                          @ifnextchar#1{myoarg@darg@{#4}}{#4{#3}}%
                                          }%<<<
                                          % <<<
                                          % macros for string comparison >>>
                                          begingroupdef:{endgroupletmy@sptoken= }:
                                          mynewdefmy@mark{my@mark@if@you@see@this@report@it}
                                          mynewdefmy@stop{my@stop@if@you@see@this@report@it}
                                          mynewdefmyparser@final{final}
                                          mynewdefmyparser@noarg{noarg}
                                          mynewdefmyparser@blankspace{blank space}
                                          % <<<
                                          mynewdef[protected]myparserdef#1#2%>>>
                                          {%
                                          defmyparserdef@twoargs{{#1}{#2}}%
                                          myparserdef@a
                                          }%<<<
                                          mynewdef[protected]myparserdef@a%>>>
                                          {%
                                          futureletmyparserdef@argmyparserdef@b
                                          }%<<<
                                          mynewdefmyparserdef@b%>>>
                                          {%
                                          ifxmyparserdef@argmy@sptoken
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {myparserdef@gobble@space}
                                          {myparserdef@c}%
                                          }%<<<
                                          mynewdef[protected]myparserdef@gobble@space%>>>
                                          {%
                                          afterassignmentmyparserdef@a
                                          letmyparserdef@arg= % space after = to get spaces, too
                                          }%<<<
                                          mynewdef[protected]myparserdef@c#1%>>>
                                          {%
                                          ifxmyparserdef@argbgroup
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {%
                                          defmyparserdef@arg{#1}%
                                          ifxmyparser@blankspacemyparserdef@arg
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {expandaftermyparserdef@dmyparserdef@twoargs{blank space space}}
                                          {expandaftermyparserdef@dmyparserdef@twoargs{#1}}%
                                          }
                                          {expandaftermyparserdef@dmyparserdef@twoargs{meaningmyparserdef@arg}}%
                                          }%<<<
                                          mynewdef[long]myparserdef@d#1#2#3%>>>
                                          {%
                                          myoarg@oarg{myparserdef@e{#1}{#2}{#3}}%
                                          }%<<<
                                          mynewdef[protectedlong]myparserdef@e#1#2#3#4#5%>>>
                                          {%
                                          % if that is the first rule for the parser, define space to be a no-op
                                          myifcsundefTF{myparser@name{#1}}%
                                          {%
                                          expandafterdef
                                          csname myparser@name{#1} all blank space spacespace typeendcsname
                                          {noarg}%
                                          expandafterdef
                                          csname myparser@name{#1} all blank space spacespace codeendcsname
                                          {myparser@getnexttoken}%
                                          % use a macro as a flag that there is at least one parser rule defined
                                          expandafterdefcsnamemyparser@name{#1}endcsname{}%
                                          }
                                          {}%
                                          % check whether the optional argument was used
                                          my@ifmark{#4}
                                          {%
                                          % use a macro as flag that there is a rule for the specified state
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{noarg}%
                                          defmyparserdef@arg@count{0}%
                                          }
                                          {%
                                          edefmyparserdef@arg@count
                                          {thenumexprmyparserdef@argcount#4my@mark}%
                                          ifnummyparserdef@arg@count>9%
                                          PackageError{my}{Too many arguments for parser rule}
                                          {A maximum of 9 parameters is supported.}%
                                          else
                                          ifnummyparserdef@arg@count=0%
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname
                                          {noarg}%
                                          else
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{#4}%
                                          fi
                                          fi
                                          }%
                                          % define what the code does
                                          expandafterdefcsname myparser@name{#1} #2 #3 codeendcsname{}%
                                          expandafterrenewcommandcsname myparser@name{#1} #2 #3 codeendcsname
                                          [myparserdef@arg@count]{#5myparser@getnexttoken}%
                                          }%<<<
                                          mynewdefmyparserdef@argcount#1%>>>
                                          {%
                                          ifxmy@mark#1%
                                          myfi@An
                                          else
                                          myfi@By
                                          fi
                                          {csname myparserdef@argcount@#1endcsname}%
                                          }%<<<
                                          mynewdefmyparserdef@argcount@m%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@o%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@O#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@d#1#2%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@D#1#2#3%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@r#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@t#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparser@name#1%>>>
                                          {%
                                          myparser #1%
                                          }%<<<
                                          mynewdefmyparser@rule#1%>>>
                                          {%
                                          myparser@currentspace #1space meaningmyparser@token
                                          }%<<<
                                          mynewdefmyparser@type#1%>>>
                                          {%
                                          myparser@rule{#1} type%
                                          }%<<<
                                          mynewdefmyparser@code#1%>>>
                                          {%
                                          myparser@rule{#1} code%
                                          }%<<<
                                          mynewdef[protected]myparserrun#1%>>>
                                          {%
                                          myifcsundefTF{myparser@name{#1}}
                                          {PackageError{my}{No parser named '#1' defined}{}}
                                          {%
                                          edefmyparser@current{myparser@name{#1}}%
                                          defmyparser@usersname{#1}%
                                          defmyparser@state{initial}%
                                          myparser@getnexttoken
                                          }%
                                          }%<<<
                                          mynewdef[protected]myparser@getnexttoken%>>>
                                          {%
                                          ifxmyparser@statemyparser@final
                                          myfi@An
                                          else
                                          myfi@By
                                          fi
                                          {%
                                          afterassignmentmyparser@getnexttoken@a
                                          letmyparser@token= % space after = to get spaces, too
                                          }%
                                          }%<<<
                                          mynewdef[protected]myparser@getnexttoken@a%>>>
                                          {%
                                          myifcsundefTF{myparser@type{myparser@state}}
                                          {%
                                          myifcsundefTF{myparser@type{all}}
                                          {%
                                          PackageError{my}
                                          {%
                                          No rule for parser 'myparser@usersname' in state
                                          'myparser@state' for 'meaningmyparser@token'.
                                          Ignoring token%
                                          }
                                          {}%
                                          myparser@getnexttoken
                                          }
                                          {myparser@handle{all}}%
                                          }
                                          {myparser@handle{myparser@state}}%
                                          }%<<<
                                          mynewdef[protected]myparser@handle#1%>>>
                                          {%
                                          expandafterifxcsnamemyparser@type{#1}endcsnamemyparser@noarg
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {csnamemyparser@code{#1}endcsname}
                                          {myparser@handle@args{#1}}%
                                          }%<<<
                                          mynewdef[protected]myparserstate#1%>>>
                                          {%
                                          defmyparser@state{#1}%
                                          }%<<<
                                          mynewdef[protected]myparser@handle@args#1%>>>
                                          {%
                                          defmyparser@stateorall{#1}%
                                          expandafterexpandafterexpandaftermyparser@handle@args@a
                                          csnamemyparser@type{#1}endcsnamemy@markmy@stop
                                          }%<<<
                                          mynewdefmyparser@handle@args@a%>>>
                                          {%
                                          myparser@handle@args@b{}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@b#1#2#3my@stop%>>>
                                          {%
                                          my@ifmark{#2}
                                          {csnamemyparser@code{myparser@stateorall}endcsname#1}
                                          {%
                                          myifcsundefTF{myparser@handle@args@#2}
                                          {PackageError{my}{Unknown argument type '#2'}{}}
                                          {csname myparser@handle@args@#2endcsname{#1}{#3}}%
                                          }%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@c#1#2%>>>
                                          {%
                                          my@ifmark{#2}
                                          {csnamemyparser@code{myparser@stateorall}endcsname#1}
                                          {myparser@handle@args@b{#1}#2my@stop}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@m#1#2#3%>>>
                                          {%
                                          myparser@handle@args@c{#1{#3}}{#2}%
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@o#1#2%>>>
                                          {%
                                          myoarg@oarg{myparser@handle@args@m{#1}{#2}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@O#1#2%>>>
                                          {%
                                          myparser@handle@args@O@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@O@#1#2#3my@stop%>>>
                                          {%
                                          myoarg@Oarg{#2}{myparser@handle@args@m{#1}{#3}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@d#1#2%>>>
                                          {%
                                          myparser@handle@args@d@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@d@#1#2#3#4my@stop%>>>
                                          {%
                                          myoarg@darg{#2}{#3}{myparser@handle@args@m{#1}{#4}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@D#1#2%>>>
                                          {%
                                          myparser@handle@args@D@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@D@#1#2#3#4#5my@stop%>>>
                                          {%
                                          myoarg@Darg{#2}{#3}{#4}{myparser@handle@args@m{#1}{#5}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@r#1#2%>>>
                                          {%
                                          myparser@handle@args@r@a{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@r@a#1#2#3my@stop%>>>
                                          {%
                                          defmyparser@handle@args@r@b##1#2{myparser@handle@args@c{#1{##1}}{#3}}%
                                          myparser@handle@args@r@b
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@t#1#2%>>>
                                          {%
                                          myparser@handle@args@t@a{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@t@a#1#2#3my@stop%>>>
                                          {%
                                          @ifnextchar#2%
                                          {@firstoftwo{myparser@handle@args@c{#1{my@mark}}{#3}}}
                                          {myparser@handle@args@c{#1{my@stop}}{#3}}%
                                          }%<<<
                                          letmyIfNoValueTFmy@ifmark
                                          letmyIfBooleanTFmy@ifmark
                                          makeatother
                                          % <<<

                                          % the sheet path parser >>>
                                          makeatletter
                                          definsertpath#1{edefsheetpath@{unexpandedexpandafter{sheetpath@#1}}}
                                          defsheetpathcurve#1#2#3#4%
                                          {%
                                          to[out=0,in=180] ++({.5*sheetlength},{#1*sheetheight})
                                          myIfBooleanTF{#3}{}{node[scale=sheetdotsize,inner sep=0pt]{.}}
                                          myIfNoValueTF{#4}{}{coordinate({#4})}
                                          to[out=0,in=180] ++({.5*sheetlength},{#2*sheetheight})
                                          }
                                          defoutputpath{drawsheetpath@;}
                                          defsheet{defsheetpath@{}myparserrun{sheet path}}
                                          makeatother
                                          myparserdef{sheet path}{initial}{the character (}[r,r)]
                                          {insertpath{({#1},{#2*sheetheight})}myparserstate{started}}
                                          myparserdef{sheet path}{initial}{the character =}
                                          {insertpath{(0,0)--++(sheetlength,0)}myparserstate{started}}
                                          myparserdef{sheet path}{started}{the character (}[r)]
                                          {insertpath{coordinate({#1})}}
                                          myparserdef{sheet path}{started}{the character =}
                                          {insertpath{--++(sheetlength,0)}}
                                          myparserdef{sheet path}{started}{the letter u}[txd()]
                                          {insertpath{sheetpathcurve{.5}{-.5}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter U}[txd()]
                                          {insertpath{sheetpathcurve{1}{-1}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter d}[txd()]
                                          {insertpath{sheetpathcurve{-.5}{.5}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter D}[txd()]
                                          {insertpath{sheetpathcurve{-1}{1}{#1}{#2}}}
                                          % making '.' a no-op, that way we can use it to end the search for an optional
                                          % argument for instance
                                          myparserdef{sheet path}{started} .{}
                                          myparserdef{sheet path}{started}{the letter x}[d()]
                                          {%
                                          myIfNoValueTF{#1}
                                          {%
                                          insertpath
                                          {--node[scale=sheetdotsize,inner sep=0pt]{.}++(sheetlength,0)}%
                                          }
                                          {%
                                          insertpath
                                          {%
                                          --node[scale=sheetdotsize,inner sep=0pt]{.}
                                          coordinate({#1})
                                          ++(sheetlength,0)
                                          }%
                                          }%
                                          }
                                          myparserdef{sheet path}{all}{the character ;}{myparserstate{final}outputpath}
                                          % <<<

                                          % sheet height and sheet length >>>
                                          pgfset
                                          {
                                          ,sheet height/.store in=sheetheight
                                          ,sheet height=1
                                          ,sheet length/.store in=sheetlength
                                          ,sheet length=1
                                          ,sheet dot size/.store in=sheetdotsize
                                          ,sheet dot size=4
                                          }
                                          %<<<

                                          begin{document}
                                          begin{tikzpicture}
                                          begin{scope}[thick, sheet height=0.75]
                                          sheet === ===d(sp1)=;
                                          sheet (0,-1) ==d(sp2)===ux =;
                                          sheet (0,-2) ==ux ===Dx =;
                                          sheet (0,-3) === ==== =;
                                          sheet (0,-4) === ===U(sp3)=;
                                          sheet (0,-5.5) ==x(b1) ===x(b2) =;
                                          end{scope}
                                          draw[dashed]
                                          (b2) -- (sp1)
                                          (b1) -- (sp2)
                                          ;
                                          end{tikzpicture}
                                          end{document}


                                          enter image description here






                                          share|improve this answer


























                                          • Wow ! This is a huge work. I'm impressed (like always I'm by the texperts ;)).

                                            – Kpym
                                            4 hours ago














                                          5












                                          5








                                          5







                                          Edit notes:




                                          • spaces can now be handled, but are ignored by default


                                          • alternative syntax for myparserdef added





                                          Inspired by Kpym's answer but thinking that the possibilities of pgfparser are insufficient, I wrote my own parser, that should be similar to pgf's, but allows the parsed elements to grab arguments. The following arguments are supported:





                                          • m a mandatory argument


                                          • r{<delim>} a mandatory argument delimited by <delim>


                                          • o an optional argument in brackets (you can test for it with myIfNoValueTF)


                                          • O{<default>} an optional argument defaulting to <default>


                                          • d<delim1><delim2> an optional argument delimited by <delim1> and <delim2> (you can test for it with myIfNoValueTF)


                                          • D<delim1><delim2>{<default>} an optional argument delimited by <delim1> and <delim2> defaulting to <default>


                                          • t<token> an optional token (you can test for it with myIfBooleanTF)


                                          Despite the fact that the argument names are inspired by xparse, none of them care for balanced delimiters (e.g., [[ab]] would not be grabbed as [ab], but as [ab with an orphaned ], so you'd have to use [{[ab]}], this is like the LaTeX2e behaviour). Also all arguments are long by nature unlike xparse where you'd need to specify that using +.



                                          You can define a parser using myparserdef{<name>}{<state>}{<meaning>}[<args>]{<code>}, with <name> the name of the parser, <state> the state, <meaning> the meaning of a token, <args> an argument string (built from the arguments listed above, up to 9 arguments are supported) and <code> the code which should be executed for that combination of <name>, <state> and <meaning>. You can switch states using myparserstate{<state>}, if you switch to final parsing is ended, the initial state is initial. All in all this is pretty similar to pgfparsers way of doing things. The biggest difference is, that my parser ignores blanks by default, however you can define an action for blanks with myparserdef{<name>}{<state>}{blank space}[<args>]{<code>}. Many consecutive blanks are considered as one.



                                          You can also use a different syntax for myparserdef namely: myparserdef{<name>}{<state>}<token>[<args>]{<code>} with <token> being a single token not surrounded by {} (spaces are ignored here, it is not checked whether <token> is really a single token, so be careful). In that case the same will be done as if you'd typed the meaning of the <token>, so myparserdef{foo}{bar}a{baz} does the same as myparserdef{foo}{bar}{the letter a}{baz}.



                                          A parser is executed using myparserrun{<name>}. A parser needs at least one rule, else an error is thrown.



                                          This parser system allows me to place coordinates inside of sheet, which was the main reason why I found pgfparser insufficient.



                                          I did all of this without using any packages, only LaTeX-Kernel macros, just for procrastinating reasons. Using for example xparse would shorten the code considerably.



                                          documentclass[tikz,border=7pt]{standalone}

                                          % my parser >>>
                                          makeatletter
                                          % logic helpers >>>
                                          longdefmyfi@An#1fi#2{fi}
                                          longdefmyfi@Ay#1fi#2{fi#2}
                                          longdefmyfi@Byfi#1{fi#1}
                                          longdefmyfi@BTbfi#1#2#3{fi#2}
                                          % <<<
                                          % mynewdef >>>
                                          @ifdefinablemyifundefTF%>>>
                                          {%
                                          defmyifundefTF#1%
                                          {%
                                          ifdefined#1%
                                          myfi@Ay
                                          else
                                          myfi@BTb
                                          fi
                                          {%
                                          ifx#1relax
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%
                                          }%
                                          }%<<<
                                          @ifdefinablemynewdef%>>>
                                          {%
                                          protecteddefmynewdef{@ifnextchar[{mynewdef@a}{mynewdef@a}}%
                                          }%<<<
                                          @ifdefinablemynewdef@a%>>>
                                          {%
                                          longdefmynewdef@a[#1]#2#3#{mynewdef@b{#1}#2{#3}}%
                                          }%<<<
                                          @ifdefinablemynewdef@b%>>>
                                          {%
                                          protectedlongdefmynewdef@b#1#2#3#4%
                                          {%
                                          myifundefTF#2%
                                          {%
                                          #1def#2#3{#4}%
                                          }
                                          {%
                                          PackageError{my}{Command string#2space already defined}{}%
                                          }
                                          }%
                                          }%<<<
                                          mynewdefmyifcsundefTF#1%>>>
                                          {%
                                          ifcsname #1endcsname
                                          myfi@Ay
                                          else
                                          myfi@BTb
                                          fi
                                          {%
                                          expandafterifxcsname #1endcsnamerelax
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%
                                          }%<<<
                                          % <<<
                                          % opt arg parsing >>>
                                          mynewdef[long]my@ifmark#1%>>>
                                          {%
                                          ifxmy@mark#1%
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@oarg#1%>>>
                                          {%
                                          @ifnextchar[{myoarg@oarg@{#1}}{#1{my@mark}}%
                                          }%<<<
                                          mynewdef[long]myoarg@oarg@#1[#2]%>>>
                                          {%
                                          #1{#2}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@Oarg#1#2%>>>
                                          {%
                                          @ifnextchar[{myoarg@oarg@{#2}}{#2{#1}}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@darg#1#2#3%>>>
                                          {%
                                          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
                                          @ifnextchar#1{myoarg@darg@{#3}}{#3{my@mark}}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@Darg#1#2#3#4%>>>
                                          {%
                                          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
                                          @ifnextchar#1{myoarg@darg@{#4}}{#4{#3}}%
                                          }%<<<
                                          % <<<
                                          % macros for string comparison >>>
                                          begingroupdef:{endgroupletmy@sptoken= }:
                                          mynewdefmy@mark{my@mark@if@you@see@this@report@it}
                                          mynewdefmy@stop{my@stop@if@you@see@this@report@it}
                                          mynewdefmyparser@final{final}
                                          mynewdefmyparser@noarg{noarg}
                                          mynewdefmyparser@blankspace{blank space}
                                          % <<<
                                          mynewdef[protected]myparserdef#1#2%>>>
                                          {%
                                          defmyparserdef@twoargs{{#1}{#2}}%
                                          myparserdef@a
                                          }%<<<
                                          mynewdef[protected]myparserdef@a%>>>
                                          {%
                                          futureletmyparserdef@argmyparserdef@b
                                          }%<<<
                                          mynewdefmyparserdef@b%>>>
                                          {%
                                          ifxmyparserdef@argmy@sptoken
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {myparserdef@gobble@space}
                                          {myparserdef@c}%
                                          }%<<<
                                          mynewdef[protected]myparserdef@gobble@space%>>>
                                          {%
                                          afterassignmentmyparserdef@a
                                          letmyparserdef@arg= % space after = to get spaces, too
                                          }%<<<
                                          mynewdef[protected]myparserdef@c#1%>>>
                                          {%
                                          ifxmyparserdef@argbgroup
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {%
                                          defmyparserdef@arg{#1}%
                                          ifxmyparser@blankspacemyparserdef@arg
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {expandaftermyparserdef@dmyparserdef@twoargs{blank space space}}
                                          {expandaftermyparserdef@dmyparserdef@twoargs{#1}}%
                                          }
                                          {expandaftermyparserdef@dmyparserdef@twoargs{meaningmyparserdef@arg}}%
                                          }%<<<
                                          mynewdef[long]myparserdef@d#1#2#3%>>>
                                          {%
                                          myoarg@oarg{myparserdef@e{#1}{#2}{#3}}%
                                          }%<<<
                                          mynewdef[protectedlong]myparserdef@e#1#2#3#4#5%>>>
                                          {%
                                          % if that is the first rule for the parser, define space to be a no-op
                                          myifcsundefTF{myparser@name{#1}}%
                                          {%
                                          expandafterdef
                                          csname myparser@name{#1} all blank space spacespace typeendcsname
                                          {noarg}%
                                          expandafterdef
                                          csname myparser@name{#1} all blank space spacespace codeendcsname
                                          {myparser@getnexttoken}%
                                          % use a macro as a flag that there is at least one parser rule defined
                                          expandafterdefcsnamemyparser@name{#1}endcsname{}%
                                          }
                                          {}%
                                          % check whether the optional argument was used
                                          my@ifmark{#4}
                                          {%
                                          % use a macro as flag that there is a rule for the specified state
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{noarg}%
                                          defmyparserdef@arg@count{0}%
                                          }
                                          {%
                                          edefmyparserdef@arg@count
                                          {thenumexprmyparserdef@argcount#4my@mark}%
                                          ifnummyparserdef@arg@count>9%
                                          PackageError{my}{Too many arguments for parser rule}
                                          {A maximum of 9 parameters is supported.}%
                                          else
                                          ifnummyparserdef@arg@count=0%
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname
                                          {noarg}%
                                          else
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{#4}%
                                          fi
                                          fi
                                          }%
                                          % define what the code does
                                          expandafterdefcsname myparser@name{#1} #2 #3 codeendcsname{}%
                                          expandafterrenewcommandcsname myparser@name{#1} #2 #3 codeendcsname
                                          [myparserdef@arg@count]{#5myparser@getnexttoken}%
                                          }%<<<
                                          mynewdefmyparserdef@argcount#1%>>>
                                          {%
                                          ifxmy@mark#1%
                                          myfi@An
                                          else
                                          myfi@By
                                          fi
                                          {csname myparserdef@argcount@#1endcsname}%
                                          }%<<<
                                          mynewdefmyparserdef@argcount@m%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@o%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@O#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@d#1#2%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@D#1#2#3%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@r#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@t#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparser@name#1%>>>
                                          {%
                                          myparser #1%
                                          }%<<<
                                          mynewdefmyparser@rule#1%>>>
                                          {%
                                          myparser@currentspace #1space meaningmyparser@token
                                          }%<<<
                                          mynewdefmyparser@type#1%>>>
                                          {%
                                          myparser@rule{#1} type%
                                          }%<<<
                                          mynewdefmyparser@code#1%>>>
                                          {%
                                          myparser@rule{#1} code%
                                          }%<<<
                                          mynewdef[protected]myparserrun#1%>>>
                                          {%
                                          myifcsundefTF{myparser@name{#1}}
                                          {PackageError{my}{No parser named '#1' defined}{}}
                                          {%
                                          edefmyparser@current{myparser@name{#1}}%
                                          defmyparser@usersname{#1}%
                                          defmyparser@state{initial}%
                                          myparser@getnexttoken
                                          }%
                                          }%<<<
                                          mynewdef[protected]myparser@getnexttoken%>>>
                                          {%
                                          ifxmyparser@statemyparser@final
                                          myfi@An
                                          else
                                          myfi@By
                                          fi
                                          {%
                                          afterassignmentmyparser@getnexttoken@a
                                          letmyparser@token= % space after = to get spaces, too
                                          }%
                                          }%<<<
                                          mynewdef[protected]myparser@getnexttoken@a%>>>
                                          {%
                                          myifcsundefTF{myparser@type{myparser@state}}
                                          {%
                                          myifcsundefTF{myparser@type{all}}
                                          {%
                                          PackageError{my}
                                          {%
                                          No rule for parser 'myparser@usersname' in state
                                          'myparser@state' for 'meaningmyparser@token'.
                                          Ignoring token%
                                          }
                                          {}%
                                          myparser@getnexttoken
                                          }
                                          {myparser@handle{all}}%
                                          }
                                          {myparser@handle{myparser@state}}%
                                          }%<<<
                                          mynewdef[protected]myparser@handle#1%>>>
                                          {%
                                          expandafterifxcsnamemyparser@type{#1}endcsnamemyparser@noarg
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {csnamemyparser@code{#1}endcsname}
                                          {myparser@handle@args{#1}}%
                                          }%<<<
                                          mynewdef[protected]myparserstate#1%>>>
                                          {%
                                          defmyparser@state{#1}%
                                          }%<<<
                                          mynewdef[protected]myparser@handle@args#1%>>>
                                          {%
                                          defmyparser@stateorall{#1}%
                                          expandafterexpandafterexpandaftermyparser@handle@args@a
                                          csnamemyparser@type{#1}endcsnamemy@markmy@stop
                                          }%<<<
                                          mynewdefmyparser@handle@args@a%>>>
                                          {%
                                          myparser@handle@args@b{}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@b#1#2#3my@stop%>>>
                                          {%
                                          my@ifmark{#2}
                                          {csnamemyparser@code{myparser@stateorall}endcsname#1}
                                          {%
                                          myifcsundefTF{myparser@handle@args@#2}
                                          {PackageError{my}{Unknown argument type '#2'}{}}
                                          {csname myparser@handle@args@#2endcsname{#1}{#3}}%
                                          }%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@c#1#2%>>>
                                          {%
                                          my@ifmark{#2}
                                          {csnamemyparser@code{myparser@stateorall}endcsname#1}
                                          {myparser@handle@args@b{#1}#2my@stop}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@m#1#2#3%>>>
                                          {%
                                          myparser@handle@args@c{#1{#3}}{#2}%
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@o#1#2%>>>
                                          {%
                                          myoarg@oarg{myparser@handle@args@m{#1}{#2}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@O#1#2%>>>
                                          {%
                                          myparser@handle@args@O@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@O@#1#2#3my@stop%>>>
                                          {%
                                          myoarg@Oarg{#2}{myparser@handle@args@m{#1}{#3}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@d#1#2%>>>
                                          {%
                                          myparser@handle@args@d@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@d@#1#2#3#4my@stop%>>>
                                          {%
                                          myoarg@darg{#2}{#3}{myparser@handle@args@m{#1}{#4}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@D#1#2%>>>
                                          {%
                                          myparser@handle@args@D@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@D@#1#2#3#4#5my@stop%>>>
                                          {%
                                          myoarg@Darg{#2}{#3}{#4}{myparser@handle@args@m{#1}{#5}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@r#1#2%>>>
                                          {%
                                          myparser@handle@args@r@a{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@r@a#1#2#3my@stop%>>>
                                          {%
                                          defmyparser@handle@args@r@b##1#2{myparser@handle@args@c{#1{##1}}{#3}}%
                                          myparser@handle@args@r@b
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@t#1#2%>>>
                                          {%
                                          myparser@handle@args@t@a{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@t@a#1#2#3my@stop%>>>
                                          {%
                                          @ifnextchar#2%
                                          {@firstoftwo{myparser@handle@args@c{#1{my@mark}}{#3}}}
                                          {myparser@handle@args@c{#1{my@stop}}{#3}}%
                                          }%<<<
                                          letmyIfNoValueTFmy@ifmark
                                          letmyIfBooleanTFmy@ifmark
                                          makeatother
                                          % <<<

                                          % the sheet path parser >>>
                                          makeatletter
                                          definsertpath#1{edefsheetpath@{unexpandedexpandafter{sheetpath@#1}}}
                                          defsheetpathcurve#1#2#3#4%
                                          {%
                                          to[out=0,in=180] ++({.5*sheetlength},{#1*sheetheight})
                                          myIfBooleanTF{#3}{}{node[scale=sheetdotsize,inner sep=0pt]{.}}
                                          myIfNoValueTF{#4}{}{coordinate({#4})}
                                          to[out=0,in=180] ++({.5*sheetlength},{#2*sheetheight})
                                          }
                                          defoutputpath{drawsheetpath@;}
                                          defsheet{defsheetpath@{}myparserrun{sheet path}}
                                          makeatother
                                          myparserdef{sheet path}{initial}{the character (}[r,r)]
                                          {insertpath{({#1},{#2*sheetheight})}myparserstate{started}}
                                          myparserdef{sheet path}{initial}{the character =}
                                          {insertpath{(0,0)--++(sheetlength,0)}myparserstate{started}}
                                          myparserdef{sheet path}{started}{the character (}[r)]
                                          {insertpath{coordinate({#1})}}
                                          myparserdef{sheet path}{started}{the character =}
                                          {insertpath{--++(sheetlength,0)}}
                                          myparserdef{sheet path}{started}{the letter u}[txd()]
                                          {insertpath{sheetpathcurve{.5}{-.5}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter U}[txd()]
                                          {insertpath{sheetpathcurve{1}{-1}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter d}[txd()]
                                          {insertpath{sheetpathcurve{-.5}{.5}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter D}[txd()]
                                          {insertpath{sheetpathcurve{-1}{1}{#1}{#2}}}
                                          % making '.' a no-op, that way we can use it to end the search for an optional
                                          % argument for instance
                                          myparserdef{sheet path}{started} .{}
                                          myparserdef{sheet path}{started}{the letter x}[d()]
                                          {%
                                          myIfNoValueTF{#1}
                                          {%
                                          insertpath
                                          {--node[scale=sheetdotsize,inner sep=0pt]{.}++(sheetlength,0)}%
                                          }
                                          {%
                                          insertpath
                                          {%
                                          --node[scale=sheetdotsize,inner sep=0pt]{.}
                                          coordinate({#1})
                                          ++(sheetlength,0)
                                          }%
                                          }%
                                          }
                                          myparserdef{sheet path}{all}{the character ;}{myparserstate{final}outputpath}
                                          % <<<

                                          % sheet height and sheet length >>>
                                          pgfset
                                          {
                                          ,sheet height/.store in=sheetheight
                                          ,sheet height=1
                                          ,sheet length/.store in=sheetlength
                                          ,sheet length=1
                                          ,sheet dot size/.store in=sheetdotsize
                                          ,sheet dot size=4
                                          }
                                          %<<<

                                          begin{document}
                                          begin{tikzpicture}
                                          begin{scope}[thick, sheet height=0.75]
                                          sheet === ===d(sp1)=;
                                          sheet (0,-1) ==d(sp2)===ux =;
                                          sheet (0,-2) ==ux ===Dx =;
                                          sheet (0,-3) === ==== =;
                                          sheet (0,-4) === ===U(sp3)=;
                                          sheet (0,-5.5) ==x(b1) ===x(b2) =;
                                          end{scope}
                                          draw[dashed]
                                          (b2) -- (sp1)
                                          (b1) -- (sp2)
                                          ;
                                          end{tikzpicture}
                                          end{document}


                                          enter image description here






                                          share|improve this answer















                                          Edit notes:




                                          • spaces can now be handled, but are ignored by default


                                          • alternative syntax for myparserdef added





                                          Inspired by Kpym's answer but thinking that the possibilities of pgfparser are insufficient, I wrote my own parser, that should be similar to pgf's, but allows the parsed elements to grab arguments. The following arguments are supported:





                                          • m a mandatory argument


                                          • r{<delim>} a mandatory argument delimited by <delim>


                                          • o an optional argument in brackets (you can test for it with myIfNoValueTF)


                                          • O{<default>} an optional argument defaulting to <default>


                                          • d<delim1><delim2> an optional argument delimited by <delim1> and <delim2> (you can test for it with myIfNoValueTF)


                                          • D<delim1><delim2>{<default>} an optional argument delimited by <delim1> and <delim2> defaulting to <default>


                                          • t<token> an optional token (you can test for it with myIfBooleanTF)


                                          Despite the fact that the argument names are inspired by xparse, none of them care for balanced delimiters (e.g., [[ab]] would not be grabbed as [ab], but as [ab with an orphaned ], so you'd have to use [{[ab]}], this is like the LaTeX2e behaviour). Also all arguments are long by nature unlike xparse where you'd need to specify that using +.



                                          You can define a parser using myparserdef{<name>}{<state>}{<meaning>}[<args>]{<code>}, with <name> the name of the parser, <state> the state, <meaning> the meaning of a token, <args> an argument string (built from the arguments listed above, up to 9 arguments are supported) and <code> the code which should be executed for that combination of <name>, <state> and <meaning>. You can switch states using myparserstate{<state>}, if you switch to final parsing is ended, the initial state is initial. All in all this is pretty similar to pgfparsers way of doing things. The biggest difference is, that my parser ignores blanks by default, however you can define an action for blanks with myparserdef{<name>}{<state>}{blank space}[<args>]{<code>}. Many consecutive blanks are considered as one.



                                          You can also use a different syntax for myparserdef namely: myparserdef{<name>}{<state>}<token>[<args>]{<code>} with <token> being a single token not surrounded by {} (spaces are ignored here, it is not checked whether <token> is really a single token, so be careful). In that case the same will be done as if you'd typed the meaning of the <token>, so myparserdef{foo}{bar}a{baz} does the same as myparserdef{foo}{bar}{the letter a}{baz}.



                                          A parser is executed using myparserrun{<name>}. A parser needs at least one rule, else an error is thrown.



                                          This parser system allows me to place coordinates inside of sheet, which was the main reason why I found pgfparser insufficient.



                                          I did all of this without using any packages, only LaTeX-Kernel macros, just for procrastinating reasons. Using for example xparse would shorten the code considerably.



                                          documentclass[tikz,border=7pt]{standalone}

                                          % my parser >>>
                                          makeatletter
                                          % logic helpers >>>
                                          longdefmyfi@An#1fi#2{fi}
                                          longdefmyfi@Ay#1fi#2{fi#2}
                                          longdefmyfi@Byfi#1{fi#1}
                                          longdefmyfi@BTbfi#1#2#3{fi#2}
                                          % <<<
                                          % mynewdef >>>
                                          @ifdefinablemyifundefTF%>>>
                                          {%
                                          defmyifundefTF#1%
                                          {%
                                          ifdefined#1%
                                          myfi@Ay
                                          else
                                          myfi@BTb
                                          fi
                                          {%
                                          ifx#1relax
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%
                                          }%
                                          }%<<<
                                          @ifdefinablemynewdef%>>>
                                          {%
                                          protecteddefmynewdef{@ifnextchar[{mynewdef@a}{mynewdef@a}}%
                                          }%<<<
                                          @ifdefinablemynewdef@a%>>>
                                          {%
                                          longdefmynewdef@a[#1]#2#3#{mynewdef@b{#1}#2{#3}}%
                                          }%<<<
                                          @ifdefinablemynewdef@b%>>>
                                          {%
                                          protectedlongdefmynewdef@b#1#2#3#4%
                                          {%
                                          myifundefTF#2%
                                          {%
                                          #1def#2#3{#4}%
                                          }
                                          {%
                                          PackageError{my}{Command string#2space already defined}{}%
                                          }
                                          }%
                                          }%<<<
                                          mynewdefmyifcsundefTF#1%>>>
                                          {%
                                          ifcsname #1endcsname
                                          myfi@Ay
                                          else
                                          myfi@BTb
                                          fi
                                          {%
                                          expandafterifxcsname #1endcsnamerelax
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%
                                          }%<<<
                                          % <<<
                                          % opt arg parsing >>>
                                          mynewdef[long]my@ifmark#1%>>>
                                          {%
                                          ifxmy@mark#1%
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@oarg#1%>>>
                                          {%
                                          @ifnextchar[{myoarg@oarg@{#1}}{#1{my@mark}}%
                                          }%<<<
                                          mynewdef[long]myoarg@oarg@#1[#2]%>>>
                                          {%
                                          #1{#2}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@Oarg#1#2%>>>
                                          {%
                                          @ifnextchar[{myoarg@oarg@{#2}}{#2{#1}}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@darg#1#2#3%>>>
                                          {%
                                          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
                                          @ifnextchar#1{myoarg@darg@{#3}}{#3{my@mark}}%
                                          }%<<<
                                          mynewdef[protectedlong]myoarg@Darg#1#2#3#4%>>>
                                          {%
                                          longdefmyoarg@darg@##1#1##2#2{##1{##2}}%
                                          @ifnextchar#1{myoarg@darg@{#4}}{#4{#3}}%
                                          }%<<<
                                          % <<<
                                          % macros for string comparison >>>
                                          begingroupdef:{endgroupletmy@sptoken= }:
                                          mynewdefmy@mark{my@mark@if@you@see@this@report@it}
                                          mynewdefmy@stop{my@stop@if@you@see@this@report@it}
                                          mynewdefmyparser@final{final}
                                          mynewdefmyparser@noarg{noarg}
                                          mynewdefmyparser@blankspace{blank space}
                                          % <<<
                                          mynewdef[protected]myparserdef#1#2%>>>
                                          {%
                                          defmyparserdef@twoargs{{#1}{#2}}%
                                          myparserdef@a
                                          }%<<<
                                          mynewdef[protected]myparserdef@a%>>>
                                          {%
                                          futureletmyparserdef@argmyparserdef@b
                                          }%<<<
                                          mynewdefmyparserdef@b%>>>
                                          {%
                                          ifxmyparserdef@argmy@sptoken
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {myparserdef@gobble@space}
                                          {myparserdef@c}%
                                          }%<<<
                                          mynewdef[protected]myparserdef@gobble@space%>>>
                                          {%
                                          afterassignmentmyparserdef@a
                                          letmyparserdef@arg= % space after = to get spaces, too
                                          }%<<<
                                          mynewdef[protected]myparserdef@c#1%>>>
                                          {%
                                          ifxmyparserdef@argbgroup
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {%
                                          defmyparserdef@arg{#1}%
                                          ifxmyparser@blankspacemyparserdef@arg
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {expandaftermyparserdef@dmyparserdef@twoargs{blank space space}}
                                          {expandaftermyparserdef@dmyparserdef@twoargs{#1}}%
                                          }
                                          {expandaftermyparserdef@dmyparserdef@twoargs{meaningmyparserdef@arg}}%
                                          }%<<<
                                          mynewdef[long]myparserdef@d#1#2#3%>>>
                                          {%
                                          myoarg@oarg{myparserdef@e{#1}{#2}{#3}}%
                                          }%<<<
                                          mynewdef[protectedlong]myparserdef@e#1#2#3#4#5%>>>
                                          {%
                                          % if that is the first rule for the parser, define space to be a no-op
                                          myifcsundefTF{myparser@name{#1}}%
                                          {%
                                          expandafterdef
                                          csname myparser@name{#1} all blank space spacespace typeendcsname
                                          {noarg}%
                                          expandafterdef
                                          csname myparser@name{#1} all blank space spacespace codeendcsname
                                          {myparser@getnexttoken}%
                                          % use a macro as a flag that there is at least one parser rule defined
                                          expandafterdefcsnamemyparser@name{#1}endcsname{}%
                                          }
                                          {}%
                                          % check whether the optional argument was used
                                          my@ifmark{#4}
                                          {%
                                          % use a macro as flag that there is a rule for the specified state
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{noarg}%
                                          defmyparserdef@arg@count{0}%
                                          }
                                          {%
                                          edefmyparserdef@arg@count
                                          {thenumexprmyparserdef@argcount#4my@mark}%
                                          ifnummyparserdef@arg@count>9%
                                          PackageError{my}{Too many arguments for parser rule}
                                          {A maximum of 9 parameters is supported.}%
                                          else
                                          ifnummyparserdef@arg@count=0%
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname
                                          {noarg}%
                                          else
                                          expandafterdefcsname myparser@name{#1} #2 #3 typeendcsname{#4}%
                                          fi
                                          fi
                                          }%
                                          % define what the code does
                                          expandafterdefcsname myparser@name{#1} #2 #3 codeendcsname{}%
                                          expandafterrenewcommandcsname myparser@name{#1} #2 #3 codeendcsname
                                          [myparserdef@arg@count]{#5myparser@getnexttoken}%
                                          }%<<<
                                          mynewdefmyparserdef@argcount#1%>>>
                                          {%
                                          ifxmy@mark#1%
                                          myfi@An
                                          else
                                          myfi@By
                                          fi
                                          {csname myparserdef@argcount@#1endcsname}%
                                          }%<<<
                                          mynewdefmyparserdef@argcount@m%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@o%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@O#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@d#1#2%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@D#1#2#3%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@r#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparserdef@argcount@t#1%>>>
                                          {%
                                          +1%
                                          myparserdef@argcount
                                          }%<<<
                                          mynewdefmyparser@name#1%>>>
                                          {%
                                          myparser #1%
                                          }%<<<
                                          mynewdefmyparser@rule#1%>>>
                                          {%
                                          myparser@currentspace #1space meaningmyparser@token
                                          }%<<<
                                          mynewdefmyparser@type#1%>>>
                                          {%
                                          myparser@rule{#1} type%
                                          }%<<<
                                          mynewdefmyparser@code#1%>>>
                                          {%
                                          myparser@rule{#1} code%
                                          }%<<<
                                          mynewdef[protected]myparserrun#1%>>>
                                          {%
                                          myifcsundefTF{myparser@name{#1}}
                                          {PackageError{my}{No parser named '#1' defined}{}}
                                          {%
                                          edefmyparser@current{myparser@name{#1}}%
                                          defmyparser@usersname{#1}%
                                          defmyparser@state{initial}%
                                          myparser@getnexttoken
                                          }%
                                          }%<<<
                                          mynewdef[protected]myparser@getnexttoken%>>>
                                          {%
                                          ifxmyparser@statemyparser@final
                                          myfi@An
                                          else
                                          myfi@By
                                          fi
                                          {%
                                          afterassignmentmyparser@getnexttoken@a
                                          letmyparser@token= % space after = to get spaces, too
                                          }%
                                          }%<<<
                                          mynewdef[protected]myparser@getnexttoken@a%>>>
                                          {%
                                          myifcsundefTF{myparser@type{myparser@state}}
                                          {%
                                          myifcsundefTF{myparser@type{all}}
                                          {%
                                          PackageError{my}
                                          {%
                                          No rule for parser 'myparser@usersname' in state
                                          'myparser@state' for 'meaningmyparser@token'.
                                          Ignoring token%
                                          }
                                          {}%
                                          myparser@getnexttoken
                                          }
                                          {myparser@handle{all}}%
                                          }
                                          {myparser@handle{myparser@state}}%
                                          }%<<<
                                          mynewdef[protected]myparser@handle#1%>>>
                                          {%
                                          expandafterifxcsnamemyparser@type{#1}endcsnamemyparser@noarg
                                          myfi@BTb
                                          fi
                                          @secondoftwo
                                          {csnamemyparser@code{#1}endcsname}
                                          {myparser@handle@args{#1}}%
                                          }%<<<
                                          mynewdef[protected]myparserstate#1%>>>
                                          {%
                                          defmyparser@state{#1}%
                                          }%<<<
                                          mynewdef[protected]myparser@handle@args#1%>>>
                                          {%
                                          defmyparser@stateorall{#1}%
                                          expandafterexpandafterexpandaftermyparser@handle@args@a
                                          csnamemyparser@type{#1}endcsnamemy@markmy@stop
                                          }%<<<
                                          mynewdefmyparser@handle@args@a%>>>
                                          {%
                                          myparser@handle@args@b{}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@b#1#2#3my@stop%>>>
                                          {%
                                          my@ifmark{#2}
                                          {csnamemyparser@code{myparser@stateorall}endcsname#1}
                                          {%
                                          myifcsundefTF{myparser@handle@args@#2}
                                          {PackageError{my}{Unknown argument type '#2'}{}}
                                          {csname myparser@handle@args@#2endcsname{#1}{#3}}%
                                          }%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@c#1#2%>>>
                                          {%
                                          my@ifmark{#2}
                                          {csnamemyparser@code{myparser@stateorall}endcsname#1}
                                          {myparser@handle@args@b{#1}#2my@stop}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@m#1#2#3%>>>
                                          {%
                                          myparser@handle@args@c{#1{#3}}{#2}%
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@o#1#2%>>>
                                          {%
                                          myoarg@oarg{myparser@handle@args@m{#1}{#2}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@O#1#2%>>>
                                          {%
                                          myparser@handle@args@O@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@O@#1#2#3my@stop%>>>
                                          {%
                                          myoarg@Oarg{#2}{myparser@handle@args@m{#1}{#3}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@d#1#2%>>>
                                          {%
                                          myparser@handle@args@d@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@d@#1#2#3#4my@stop%>>>
                                          {%
                                          myoarg@darg{#2}{#3}{myparser@handle@args@m{#1}{#4}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@D#1#2%>>>
                                          {%
                                          myparser@handle@args@D@{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@D@#1#2#3#4#5my@stop%>>>
                                          {%
                                          myoarg@Darg{#2}{#3}{#4}{myparser@handle@args@m{#1}{#5}}%
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@r#1#2%>>>
                                          {%
                                          myparser@handle@args@r@a{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@r@a#1#2#3my@stop%>>>
                                          {%
                                          defmyparser@handle@args@r@b##1#2{myparser@handle@args@c{#1{##1}}{#3}}%
                                          myparser@handle@args@r@b
                                          }%<<<
                                          mynewdef[long]myparser@handle@args@t#1#2%>>>
                                          {%
                                          myparser@handle@args@t@a{#1}#2my@stop
                                          }%<<<
                                          mynewdef[protectedlong]myparser@handle@args@t@a#1#2#3my@stop%>>>
                                          {%
                                          @ifnextchar#2%
                                          {@firstoftwo{myparser@handle@args@c{#1{my@mark}}{#3}}}
                                          {myparser@handle@args@c{#1{my@stop}}{#3}}%
                                          }%<<<
                                          letmyIfNoValueTFmy@ifmark
                                          letmyIfBooleanTFmy@ifmark
                                          makeatother
                                          % <<<

                                          % the sheet path parser >>>
                                          makeatletter
                                          definsertpath#1{edefsheetpath@{unexpandedexpandafter{sheetpath@#1}}}
                                          defsheetpathcurve#1#2#3#4%
                                          {%
                                          to[out=0,in=180] ++({.5*sheetlength},{#1*sheetheight})
                                          myIfBooleanTF{#3}{}{node[scale=sheetdotsize,inner sep=0pt]{.}}
                                          myIfNoValueTF{#4}{}{coordinate({#4})}
                                          to[out=0,in=180] ++({.5*sheetlength},{#2*sheetheight})
                                          }
                                          defoutputpath{drawsheetpath@;}
                                          defsheet{defsheetpath@{}myparserrun{sheet path}}
                                          makeatother
                                          myparserdef{sheet path}{initial}{the character (}[r,r)]
                                          {insertpath{({#1},{#2*sheetheight})}myparserstate{started}}
                                          myparserdef{sheet path}{initial}{the character =}
                                          {insertpath{(0,0)--++(sheetlength,0)}myparserstate{started}}
                                          myparserdef{sheet path}{started}{the character (}[r)]
                                          {insertpath{coordinate({#1})}}
                                          myparserdef{sheet path}{started}{the character =}
                                          {insertpath{--++(sheetlength,0)}}
                                          myparserdef{sheet path}{started}{the letter u}[txd()]
                                          {insertpath{sheetpathcurve{.5}{-.5}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter U}[txd()]
                                          {insertpath{sheetpathcurve{1}{-1}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter d}[txd()]
                                          {insertpath{sheetpathcurve{-.5}{.5}{#1}{#2}}}
                                          myparserdef{sheet path}{started}{the letter D}[txd()]
                                          {insertpath{sheetpathcurve{-1}{1}{#1}{#2}}}
                                          % making '.' a no-op, that way we can use it to end the search for an optional
                                          % argument for instance
                                          myparserdef{sheet path}{started} .{}
                                          myparserdef{sheet path}{started}{the letter x}[d()]
                                          {%
                                          myIfNoValueTF{#1}
                                          {%
                                          insertpath
                                          {--node[scale=sheetdotsize,inner sep=0pt]{.}++(sheetlength,0)}%
                                          }
                                          {%
                                          insertpath
                                          {%
                                          --node[scale=sheetdotsize,inner sep=0pt]{.}
                                          coordinate({#1})
                                          ++(sheetlength,0)
                                          }%
                                          }%
                                          }
                                          myparserdef{sheet path}{all}{the character ;}{myparserstate{final}outputpath}
                                          % <<<

                                          % sheet height and sheet length >>>
                                          pgfset
                                          {
                                          ,sheet height/.store in=sheetheight
                                          ,sheet height=1
                                          ,sheet length/.store in=sheetlength
                                          ,sheet length=1
                                          ,sheet dot size/.store in=sheetdotsize
                                          ,sheet dot size=4
                                          }
                                          %<<<

                                          begin{document}
                                          begin{tikzpicture}
                                          begin{scope}[thick, sheet height=0.75]
                                          sheet === ===d(sp1)=;
                                          sheet (0,-1) ==d(sp2)===ux =;
                                          sheet (0,-2) ==ux ===Dx =;
                                          sheet (0,-3) === ==== =;
                                          sheet (0,-4) === ===U(sp3)=;
                                          sheet (0,-5.5) ==x(b1) ===x(b2) =;
                                          end{scope}
                                          draw[dashed]
                                          (b2) -- (sp1)
                                          (b1) -- (sp2)
                                          ;
                                          end{tikzpicture}
                                          end{document}


                                          enter image description here







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited 16 hours ago

























                                          answered yesterday









                                          SkillmonSkillmon

                                          23.8k12248




                                          23.8k12248













                                          • Wow ! This is a huge work. I'm impressed (like always I'm by the texperts ;)).

                                            – Kpym
                                            4 hours ago



















                                          • Wow ! This is a huge work. I'm impressed (like always I'm by the texperts ;)).

                                            – Kpym
                                            4 hours ago

















                                          Wow ! This is a huge work. I'm impressed (like always I'm by the texperts ;)).

                                          – Kpym
                                          4 hours ago





                                          Wow ! This is a huge work. I'm impressed (like always I'm by the texperts ;)).

                                          – Kpym
                                          4 hours ago


















                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481125%2fdrawing-ramified-coverings-with-tikz%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum

                                          He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

                                          Slayer Innehåll Historia | Stil, komposition och lyrik | Bandets betydelse och framgångar | Sidoprojekt och samarbeten | Kontroverser | Medlemmar | Utmärkelser och nomineringar | Turnéer och festivaler | Diskografi | Referenser | Externa länkar | Navigeringsmenywww.slayer.net”Metal Massacre vol. 1””Metal Massacre vol. 3””Metal Massacre Volume III””Show No Mercy””Haunting the Chapel””Live Undead””Hell Awaits””Reign in Blood””Reign in Blood””Gold & Platinum – Reign in Blood””Golden Gods Awards Winners”originalet”Kerrang! Hall Of Fame””Slayer Looks Back On 37-Year Career In New Video Series: Part Two””South of Heaven””Gold & Platinum – South of Heaven””Seasons in the Abyss””Gold & Platinum - Seasons in the Abyss””Divine Intervention””Divine Intervention - Release group by Slayer””Gold & Platinum - Divine Intervention””Live Intrusion””Undisputed Attitude””Abolish Government/Superficial Love””Release “Slatanic Slaughter: A Tribute to Slayer” by Various Artists””Diabolus in Musica””Soundtrack to the Apocalypse””God Hates Us All””Systematic - Relationships””War at the Warfield””Gold & Platinum - War at the Warfield””Soundtrack to the Apocalypse””Gold & Platinum - Still Reigning””Metallica, Slayer, Iron Mauden Among Winners At Metal Hammer Awards””Eternal Pyre””Eternal Pyre - Slayer release group””Eternal Pyre””Metal Storm Awards 2006””Kerrang! Hall Of Fame””Slayer Wins 'Best Metal' Grammy Award””Slayer Guitarist Jeff Hanneman Dies””Bullet-For My Valentine booed at Metal Hammer Golden Gods Awards””Unholy Aliance””The End Of Slayer?””Slayer: We Could Thrash Out Two More Albums If We're Fast Enough...””'The Unholy Alliance: Chapter III' UK Dates Added”originalet”Megadeth And Slayer To Co-Headline 'Canadian Carnage' Trek”originalet”World Painted Blood””Release “World Painted Blood” by Slayer””Metallica Heading To Cinemas””Slayer, Megadeth To Join Forces For 'European Carnage' Tour - Dec. 18, 2010”originalet”Slayer's Hanneman Contracts Acute Infection; Band To Bring In Guest Guitarist””Cannibal Corpse's Pat O'Brien Will Step In As Slayer's Guest Guitarist”originalet”Slayer’s Jeff Hanneman Dead at 49””Dave Lombardo Says He Made Only $67,000 In 2011 While Touring With Slayer””Slayer: We Do Not Agree With Dave Lombardo's Substance Or Timeline Of Events””Slayer Welcomes Drummer Paul Bostaph Back To The Fold””Slayer Hope to Unveil Never-Before-Heard Jeff Hanneman Material on Next Album””Slayer Debut New Song 'Implode' During Surprise Golden Gods Appearance””Release group Repentless by Slayer””Repentless - Slayer - Credits””Slayer””Metal Storm Awards 2015””Slayer - to release comic book "Repentless #1"””Slayer To Release 'Repentless' 6.66" Vinyl Box Set””BREAKING NEWS: Slayer Announce Farewell Tour””Slayer Recruit Lamb of God, Anthrax, Behemoth + Testament for Final Tour””Slayer lägger ner efter 37 år””Slayer Announces Second North American Leg Of 'Final' Tour””Final World Tour””Slayer Announces Final European Tour With Lamb of God, Anthrax And Obituary””Slayer To Tour Europe With Lamb of God, Anthrax And Obituary””Slayer To Play 'Last French Show Ever' At Next Year's Hellfst””Slayer's Final World Tour Will Extend Into 2019””Death Angel's Rob Cavestany On Slayer's 'Farewell' Tour: 'Some Of Us Could See This Coming'””Testament Has No Plans To Retire Anytime Soon, Says Chuck Billy””Anthrax's Scott Ian On Slayer's 'Farewell' Tour Plans: 'I Was Surprised And I Wasn't Surprised'””Slayer””Slayer's Morbid Schlock””Review/Rock; For Slayer, the Mania Is the Message””Slayer - Biography””Slayer - Reign In Blood”originalet”Dave Lombardo””An exclusive oral history of Slayer”originalet”Exclusive! Interview With Slayer Guitarist Jeff Hanneman”originalet”Thinking Out Loud: Slayer's Kerry King on hair metal, Satan and being polite””Slayer Lyrics””Slayer - Biography””Most influential artists for extreme metal music””Slayer - Reign in Blood””Slayer guitarist Jeff Hanneman dies aged 49””Slatanic Slaughter: A Tribute to Slayer””Gateway to Hell: A Tribute to Slayer””Covered In Blood””Slayer: The Origins of Thrash in San Francisco, CA.””Why They Rule - #6 Slayer”originalet”Guitar World's 100 Greatest Heavy Metal Guitarists Of All Time”originalet”The fans have spoken: Slayer comes out on top in readers' polls”originalet”Tribute to Jeff Hanneman (1964-2013)””Lamb Of God Frontman: We Sound Like A Slayer Rip-Off””BEHEMOTH Frontman Pays Tribute To SLAYER's JEFF HANNEMAN””Slayer, Hatebreed Doing Double Duty On This Year's Ozzfest””System of a Down””Lacuna Coil’s Andrea Ferro Talks Influences, Skateboarding, Band Origins + More””Slayer - Reign in Blood””Into The Lungs of Hell””Slayer rules - en utställning om fans””Slayer and Their Fans Slashed Through a No-Holds-Barred Night at Gas Monkey””Home””Slayer””Gold & Platinum - The Big 4 Live from Sofia, Bulgaria””Exclusive! Interview With Slayer Guitarist Kerry King””2008-02-23: Wiltern, Los Angeles, CA, USA””Slayer's Kerry King To Perform With Megadeth Tonight! - Oct. 21, 2010”originalet”Dave Lombardo - Biography”Slayer Case DismissedArkiveradUltimate Classic Rock: Slayer guitarist Jeff Hanneman dead at 49.”Slayer: "We could never do any thing like Some Kind Of Monster..."””Cannibal Corpse'S Pat O'Brien Will Step In As Slayer'S Guest Guitarist | The Official Slayer Site”originalet”Slayer Wins 'Best Metal' Grammy Award””Slayer Guitarist Jeff Hanneman Dies””Kerrang! Awards 2006 Blog: Kerrang! Hall Of Fame””Kerrang! Awards 2013: Kerrang! Legend”originalet”Metallica, Slayer, Iron Maien Among Winners At Metal Hammer Awards””Metal Hammer Golden Gods Awards””Bullet For My Valentine Booed At Metal Hammer Golden Gods Awards””Metal Storm Awards 2006””Metal Storm Awards 2015””Slayer's Concert History””Slayer - Relationships””Slayer - Releases”Slayers officiella webbplatsSlayer på MusicBrainzOfficiell webbplatsSlayerSlayerr1373445760000 0001 1540 47353068615-5086262726cb13906545x(data)6033143kn20030215029