LaTeX forum ⇒ Graphics, Figures & TablesNumber line

Information and discussion about graphics, figures & tables in LaTeX documents.
Posts: 5
Joined: Mon Jul 27, 2009 5:32 pm

Number line

Postby jlamber » Fri Oct 09, 2009 10:48 pm


I am trying to create a number line such as those on page six of this paper
(417.32 KiB) Downloaded 1453 times

I have looked at coordsys package but it's hard to control the interval and the length of the number line. Do you have any other suggestions?

Please help.
Thank You,

Recommended reading 2021: • •
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Number line

Postby torbjorn t. » Fri Oct 09, 2009 11:34 pm

One option is to use TikZ. Load the package with \usepackage{tikz}, and then do something like this:
\draw (0,0) -- (12.5,0);
\foreach \x in {0,3,6,9,12}
\draw[shift={(\x,0)},color=black] (0pt,3pt) -- (0pt,0pt);
\foreach \x in {0,1,2,3,4,5,6,7,8,9,10,11,12}
\draw[shift={(\x,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below] 
\draw (0,0) node[above]{$0$};
\draw (3,0) node[above]{$1$};
\draw (6,0) node[above]{$2$};
\draw (9,0) node[above]{$3$};
\draw (12,0) node[above]{$4$};

The above code produces output like in the attached PDF. Note that I know very little of LaTeX compared to some other people here, so there may well be better options available.
(20.67 KiB) Downloaded 1466 times

User avatar
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Number line

Postby localghost » Sat Oct 10, 2009 10:18 am

I may venture some modifications to the code of torbjorn t. that optimize it slightly.

    \foreach \x/\xtext in {0/0,3/1,6/2,9/3,12/4}
      \draw(\x,0pt)--(\x,3pt) node[above] {\xtext};
    \foreach \x in {0,1,...,12}
      \draw(\x,0pt)--(\x,-3pt) node[below] {$\frac{\x}{3}$};

For more information refer to the pgf/tikZ manual. Could be done similar with pstricks.

Best regards and welcome to the board
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 9 guests