Graphics, Figures & TablesHow is a number line for an interval created?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ben8090
Posts: 1
Joined: Sat Jun 19, 2010 3:51 am

How is a number line for an interval created?

Post by ben8090 »

By that I mean a number line with specific interval values marked. For example an interval of [-1,3). If it's possible, I prefer that the markings be brackets and parentheses on the number line, but if I could create anything like what you see on this URL (http://www.nipissingu.ca/calculus/tutorials/sets.html) that would be excellent. So if there's any package or program that can generate these and works well, I'd like to know, and an example of code would really help, too.

Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How is a number line for an interval created?

Post by gmedina »

Hi,

you can use the PGF/TikZ package. Take a look at the following very simple example:

Code: Select all

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

\newcommand\Interval[4]{%
  \begin{tikzpicture}[text height=1ex]%
    \draw[<-] (0,0) -- (1,0); 
    \draw[{#3-#4}] (1,0) node[label=below:{#1}] {} -- (2,0) node[label=below:{#2}] {};
    \draw[->] (2,0) -- (3,0);
  \end{tikzpicture}
}

\begin{document}

\Interval{-3}{8}{(}{)}

\Interval{1}{4}{[}{)}

\Interval{-4}{-1}{(}{]}

\Interval{0}{4}{[}{]}

\end{document}
Of course, my example must be taken just as a starting point; you can improve it.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply