2

I was trying to draw a number line such as:

|---+----+-----+----- ....    | 
0  0.1  0.2    0.3       0.9  1

However, the dot number line doesn't shift as I had expected, any help is appreciated.

enter image description here

The source are:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}

% draw arrow line
\draw[latex-latex] (-0.5,0) -- (10.5, 0);
% draw vertical bar
\foreach \x in {0, 1, ..., 10}
    \draw[shift={(\x,0)}, color=black] (0pt, 3pt) -- (0pt, -3pt);

\draw[color=black] (0pt, 0pt) -- (0pt, -3pt) 
        node[below] {\Large $0$};

\draw[shift={(10,0)}, color=black] (0pt, 0pt) -- (0pt, -3pt)
        node[below] {\Large $1$};

\foreach \x in {1,2, ..., 9}
    draw[shift={(\x,0)}, color=black] (0pt, 0pt) -- (0pt, -3pt)
        node[below] {$0.\x$};

\end{tikzpicture}
\end{document}

1 Answer 1

3

Your code is missing a backslash, \, in front of the last draw command.

The last code segment should be as follows:

\foreach \x in {1,2, ..., 9}
    \draw[shift={(\x,0)}, color=black] (0pt, 0pt) -- (0pt, -3pt)
        node[below] {$0.\x$};

Replace the last code segment with the code above (just add the missing backslash), and you should get the following output:

Output

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .