1

I want to draw the following diagram in LaTeX. How can I do this?

enter image description here

  • 1
    Do you have a specific function, or you simply want a curvy shape. I suggest learning Tikz. – Bill N Mar 13 '16 at 3:18
  • 1
    Do you want others to draw it for you or do you want to learn how to draw it? You are more likely to get help if you post an example of what you have tried so far. (This will also help people show you where you have room to learn.) This question is a good example of what you should do here. – jon Mar 13 '16 at 4:56
  • @jon Perhaps pointing to a question that's similar to the OP's might better help the OP understand what could be done for a MWE. – A.Ellett Mar 13 '16 at 5:15
  • @A.Ellett -- I know what you mean, but I don't think it's true in principle. That said, I'm not opposed to someone posting a better example (I just saw this one about a minute before I saw this question, which is why I used it), but I mostly ignore the drawing questions and I don't know of any off-hand, so I'd rather leave that to someone else. If one is posted, I'll delete that comment along with this one. – jon Mar 13 '16 at 5:39
  • Crosspost – Johannes_B Mar 13 '16 at 12:55
2
\documentclass{article}
\usepackage{pstricks-add}
\psset{shortput=nab}
\begin{document}

\begin{pspicture}(-0.5,-1)(13,3)
\pnodes(0,0){a}(2,0){ab}(4,0){b}(8,0){da}(12,0){db}
\psline[ArrowInsidePos=0.5,ArrowInside=-|]{[-]}(b)
\uput[-90](a){$a$}\uput[90](ab){$t$}\uput[-90](b){$b$}
\nccurve[ArrowInside=->,ArrowInsidePos=0.5,arrowscale=2,
         nodesep=5pt,angleA=45,angleB=135]{b}{da}^{$\delta$}
\nccurve[ArrowInside=->,ArrowInsidePos=0.5,arrowscale=2,
angleA=-45,angleB=135]{*-*}{da}{db}^{$\delta(t)$}
\uput[-90](8,0){$\delta(a)$}\uput[-90](12,0){$\delta(b)$}
\end{pspicture}

\end{document}

enter image description here

  • \psline[ArrowInsidePos=0.5,ArrowInside=-|]{[-]}(b) \uput[-90](a){$a$}\uput[90](ab){$t$}\uput[-90](b){$b$} \nccurve[ArrowInside=->,ArrowInsidePos=0.5,arrowscale=2, nodesep=5pt,angleA=45,angleB=135]{b}{da}^{$\delta$} giving me error as undefined control sequence ! – maths_freak_007 Mar 13 '16 at 13:05
  • did you run the example with xelatex? – user2478 Mar 13 '16 at 13:59
  • what is xelatex? – maths_freak_007 Mar 13 '16 at 15:00
  • a command, just like pdflatex, but xelatex can handle unicode, pdflatex not. – user2478 Mar 13 '16 at 15:03
  • but the output file PDF does not contain the curve? – maths_freak_007 Mar 14 '16 at 11:27
2

As I already answered to your cross-post at LaTeX-Community.org, here's my answer as well. It is using nodes and the to operation.

I used relative positions, by changing the values you can tweak the drawing.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings,quotes}
\begin{document}
\begin{tikzpicture}[
  dot/.style = {circle, draw, fill, inner sep=2pt},
  decoration = {
    markings,
    mark=at position 0.5 with {\pgftransformscale{2}\arrow{stealth}}},
  ]
  \node (gamma-a) [dot,"$\gamma(a)$"] {};
  \node (gamma-b) [above right = 1cm   and 4 cm of gamma-a,
                   dot,"$\gamma(b)$"] {};
  \node (below)   [below right = 0.5cm and 1 cm of gamma-a] {};
  \node (above)   [above left  = 0.5cm and 1 cm of gamma-b] {};
  \draw [postaction={decorate}] (gamma-a)
    to [out=0, in=180] (below)
    to [out=0, in=180] (above)
    to [out=0, in=180] (gamma-b);
  \node (gamma-t) [below left  = 0.1cm and 2.2 cm of gamma-b]
    {$\gamma(t)$};
\end{tikzpicture}
\end{document}

transformation

I omitted the rest of the drawing when I noticed the cross-post. As you did not mention that cross-post here, you caused me unnecessary work there.

2

Here's a Metapost version. Follow the link for details about MP.

enter image description here

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

picture linear, curved;
path bracket;
bracket = (1/2,1)--(0,1)--(0,-1)--(1/2,-1);

linear = image(
  path line;
  line = (left--right) scaled 42;

  draw line;
  draw bracket             scaled 3 shifted point 0 of line;
  draw bracket rotated 180 scaled 3 shifted point 1 of line;
  draw (down--up) scaled 2 shifted point 1/2 of line;

  label.top(btex $a$ etex, point   0 of line shifted 3 up);
  label.top(btex $t$ etex, point 1/2 of line shifted 3 up);
  label.top(btex $b$ etex, point   1 of line shifted 3 up);
);

curved = image(
  path line;
  line = (42 left { dir -70 } .. 42 right { dir -60 }) rotated 7;

  drawarrow subpath (0, 9/16) of line; draw subpath (1/2, 1) of line;

  dotlabel.lft (btex $\gamma(a)$ etex, point 0 of line);
     label.ulft(btex $\gamma(t)$ etex, point 9/16 of line);
  dotlabel.rt  (btex $\gamma(b)$ etex, point 1 of line);

) shifted 200 right;

draw linear;
draw curved;

bboxmargin := 12;
path transition;
transition = center linear { dir 30 } .. center curved
             cutbefore bbox linear
             cutafter  bbox curved;

drawarrow transition withcolor .67 red;
label.top(btex $\gamma$ etex, point 1/2 of transition);

endfig;
end.

For this sort of diagram with two separate areas, it is sometimes convenient to draw them independently. You can use the image() function to save a group of drawing commands as a picture variable, which you can then place as desired. This makes it easier to move part of a drawing as a unit.

1

Here is one solution with Tikz. The most non-intuitive aspect is placing arrows in the middle of a curve. That aspect is covered in the decorations section of the tikz manual (and lot of questions here in tex.SE). The next is generating curved lines. I have used the to[out=, in=] method here. The brackets and dots at the ends of curves can be made with the arrow head shapes made available by TikZ (This makes the image non scalable I think). The curved line in the middle doesn't touch the interval or the final curve. This can be doe either by shorten >= syntax or relative coordinate method. I used the latter because the shorten method did not play nicely with the decoration arrow tip.

It doesn't scale well due to the use of arrow heads for denoting the closed interval and due to presence of manual distance adjustments and some inconsistent way of placing arrows in the middle of a curve.

Some code is based on TikZ manual(3.0.x) and Visual Tikz pdf ( https://tex.stackexchange.com/a/9123/95229 )

\documentclass[tikz]{standalone}
% for square and circle arrow heads
\usetikzlibrary{arrows.meta}
% for arrows in middle of line
\usetikzlibrary{decorations.markings}
% for relative node positioning
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[
    node distance=0.5cm,
    decoration={
        %based on Tikz manual 48.5.1 Arrow Tip Markings
        markings,
        mark=at position .5 with {\arrow{>}},
    }
]
% place and name the coordinates.
% The coordinates below are chosen based on convenience only.
\coordinate (a) at (0,0);
\coordinate (b) at (2,0);
\coordinate (c) at (5,0);
\coordinate (d) at (8,0);

% draw line from a to b with bracket shaped arrow head at both ends
% add a node named t at 50% distance.
\draw [Bracket-Bracket
       % based Visual Tikz pdf (french)
       % Version 0.60 section 3.10.2
      ]
      (a) -- node [pos=0.5] (t){} (b);
% put label above/below the nodes
\node [below of=a]{$a$};
\node [below of=b]{$b$};
\node [above of=t, node distance=0.3cm]{$t$};

% draw a small line at node t using relative positioning
\draw (t) +(0,-2pt) -- +(0,2pt);

% draw curved line and add arrow in the middle of the curve
\draw [postaction={decorate}]
      ($(b)+(4pt,4pt)$) to[out=45, in=135]
          node[pos=0.5](f){}
      ($(c)+(-4pt,4pt)$);

\draw [Circle-Circle,
       postaction={decorate}]
      (c) to[out=-45, in=135]
          node[pos=0.5](e){}
      (d);

\node [below of=c]{$\delta(a)$};
\node [above of=d]{$\delta(b)$};
\node [above of=e, node distance=0.3cm]{$\delta(t)$};
\node [above of=f, node distance=0.3cm]{$\delta$};

\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.