TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I do this?

enter image description here

I do not know how to do this. Is it possible to do it in LaTeX or should I create a figure with GeoGebra and insert it?

share|improve this question
Looks pretty simple for TikZ and friends. Have you tried something already? What are the specifications? And what has that to do with the Table of Contents? – Qrrbrbirlbel Oct 27 '13 at 17:06
Is this an illustration to a function domain? – m0nhawk Oct 27 '13 at 17:11
I thought of something like tex.stackexchange.com/questions/94246/how-to-draw-intervals @Qrrbrbirlbel – Henfe Oct 27 '13 at 17:14
yes, it is the domain of a function @m0nhawk – Henfe Oct 27 '13 at 17:15
up vote 17 down vote accepted

A little fun with TikZ and PGFkeys.


  fromto/.code=\pgfqkeys{/tikz/fromto}{#1}, fromto/.cd,
    from/.initial=0, to/.initial=10,  min/.initial=0, max/.initial=10,
    fromto style/.style={circle, draw, inner sep=+0pt, minimum size=+3pt},
    include/.style={/tikz/fromto/fromto style, fill=black},
    exclude/.style={/tikz/fromto/fromto style, fill=white},
    From/.is choice,
      From/in/.style={/tikz/fromto/from style/.style={fromto/include}},
      From/ex/.style={/tikz/fromto/from style/.style={fromto/exclude}},
      From/no/.style={/tikz/fromto/from style/.style={coordinate, label/.style}},
    To/.is choice,
      To/in/.style={/tikz/fromto/to style/.style={fromto/fromto style, fromto/include}},
      To/ex/.style={/tikz/fromto/to style/.style={fromto/fromto style, fromto/exclude}},
      To/no/.style={/tikz/fromto/to style/.style={coordinate, label/.style}},
    From=no, To=no,
    every fromto picture/.style={x=2.5mm, baseline, >=latex,
      every label/.style={overlay, /utils/exec=\scriptsize}},
    range/.style={decoration={snake, amplitude=+1pt, segment length=+2pt}, decorate}}
  \tikzpicture[fromto={#1}, fromto/every fromto picture]
    \draw[fromto/axes/.try] (right:\pgfkeysvalueof{/tikz/fromto/min}) --
      (right:\pgfkeysvalueof{/tikz/fromto/max}) -- ++ (right:10\pgflinewidth);
    \draw[fromto/range/.try] (right:\pgfkeysvalueof{/tikz/fromto/from})
      -- (right:\pgfkeysvalueof{/tikz/fromto/to})
      node[at start, fromto/from style, label=$\pgfkeysvalueof{/tikz/fromto/from}$]{} 
      node[at end, fromto/to style, label=$\pgfkeysvalueof{/tikz/fromto/to}$]{};
\item \fromto[from=3, From=ex]
\item \fromto[to=7, To=in]
\item \fromto[from=3, From=in, to=6, To=ex]
\item \fromto[min=-5, max=15, from=-3, to=14, From=in, To=ex]


enter image description here

share|improve this answer
thank you very much, it was exactly what I was looking for. – Henfe Oct 27 '13 at 17:48
When I insert it in my tex, the result was a little small. How could I increase the size? Thank you. @Qrrbrbirlbel – Henfe Oct 28 '13 at 11:39
@Henfe: Without compiling the code I think you can just add a 'scale=2' (or any other float > 1) to the \tikzpicture command. I would try \tikzpicture[scale=1.6,fromto={#1}, fromto/every fromto picture]. – Habi Oct 28 '13 at 13:15
@Henfe What does “small” mean? I have added x = 2.5mm (default: 1cm) to the every fromto picture style so that it looks more like your picture. You can set this to any other length so that the arrow gets longer or shorter. The nodes with the numbers are set in \scriptsize (see the every label style). Then you can change the line width or the parameters of the snake line. And of course, you can also use scale. – Qrrbrbirlbel Oct 29 '13 at 13:10

With PSTricks just for fun!


    % x > 3
    % x >= 3
    % 2 <= x < 3
    % x < 2 or x >=3

enter image description here


  • coilheight is a factor (dimensionless).
  • coilwidth is a length.
  • coilarm is a length.

The formula relating them is given as follows.

If L represents the distance from (x1,y1) to (x2,y2) in \pszigzag(x1,y1)(x2,y2), N represents the number of winding then


Fortunately, you don't need to keep the number of winding equal for each case above. That is why we just let the number of winding gets automatically assigned.

If you are interested to assign the number of winding, see my another answer here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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