我试图绘制一条数轴,例如:
|---+----+-----+----- .... |
0 0.1 0.2 0.3 0.9 1
但是,点数线并没有像我预期的那样移动,如能得到任何帮助我将不胜感激。
资料来源为:
\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
\
您的代码在最后一个命令前缺少一个反斜杠draw
。
最后的代码段应该如下:
\foreach \x in {1,2, ..., 9}
\draw[shift={(\x,0)}, color=black] (0pt, 0pt) -- (0pt, -3pt)
node[below] {$0.\x$};
将最后一段代码替换为上面的代码(只需添加缺失的反斜杠),您应该得到以下输出: