2. Number Lines - manual๏
2.1. A number line diagram with answers๏
2.2. number lines LaTeX๏
A LaTeX .tex file consists of two parts, the preamble and the main document.
2.3. LaTeX preamble๏
% numberline
\documentclass[preview,12pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary {arrows.meta}
\usetikzlibrary{bending}
\usepackage[a4paper, portrait, margin=1cm]{geometry}
\def\jumpheight{10}
\def\qgap{\rule[-1pt]{1.0em}{.25pt}}
% modify values for number lines
\def\startval{-3}
\def\endval{2}
% values for display
\def\startvaltxt{\startval}
\def\endvaltxt{\endval}
\def\changevaltxt{+5}
\def\equtxt{-3 + 5 = 2}
% end modify values for number lines
2.3.1. Document class๏
\documentclass[preview,12pt]{standalone}
is used to define a document that can be used to create graphics that are self-contained and can be easily included in other documents.2.3.2. tikz package๏
\usepackage{tikz}
imports the TikZ package which allows you to create diagrams and graphics programmatically, such as points, lines and paths, circles, ellipses and rectangles.\usetikzlibrary{positioning}
is used to import the positioning library which provides advanced positioning options for nodes (points in a diagram that can be referenced and used to draw lines or shapes).\usetikzlibrary{arrows.meta}
loads the arrows.meta library, which provides more options for customizing the appearance of arrows in tikz diagrams. This library allows you to use different arrow tip styles and to adjust the size and shape of arrow tips.\usetikzlibrary{bending}
loads the bending library, which improves the appearance of arrows that are attached to curved lines. This library makes the arrow tips follow the curvature of the line, resulting in a more natural-looking bend.2.3.3. arrows๏
\usetikzlibrary {arrows.meta}
and \usetikzlibrary{bending}
to create various types of arrows with TikZ.2.3.4. Macro definitions๏
\def\jumpheight{10}
is used for consistency and easy adjustment of the height that the arrow goes up from the points in the number line.\def\qgap{\rule[-1pt]{1.0em}{.25pt}}
is used for placing an underline for space to write answers on a number line used in a question.% modify values for number lines
\def\startval{-3}
\def\endval{2}
% values for display
\def\startvaltxt{\startval}
\def\endvaltxt{\endval}
\def\changevaltxt{+5}
\def\equtxt{-3 + 5 = 2}
% end modify values for number lines
2.3.5. Macro definitions and Variables๏
\def
is used to define new commands in LaTeX.\def\commandname{replacement text}
.\def\startval{-3}
defines a new command named, \startval
, that takes no arguments and expands to the text -3
.2.3.5.1. The document environment๏
\begin{document}
\begin{tikzpicture}[scale=0.75]
% axis, arrow style to-to
\draw[{To[scale=1.3]}-{To[scale=1.3]}, line width=1pt] (-10.4, 0) -- (10.4, 0);
% tick marks
\foreach \x in {-10,-9,...,10}
\draw[shift={(\x,0)},color=black, line width=1pt] (0pt,-14pt) -- (0pt,0pt);
% numbers along each axis
\foreach \x in {-10,0,10}
\draw[shift={(\x,-0.8)},color=black] node[font=\large,text height=12pt] {$\x$};
% to display variables
\draw[shift={(\startval,-0.8)},color=black] node[font=\large,text height=12pt] {$\startvaltxt$};
\draw[shift={(\endval,-0.8)},color=black] node[font=\large,text height=12pt] {$\endvaltxt$};
% dots
\filldraw[black] (\startval,0) circle (4pt) node[above,yshift=-2pt] (a) {};
\filldraw[black] (\endval,0) circle (4pt) node[above,yshift=-2pt] (b) {};
% arrow
\draw[-{To[scale=1.3, bend]},line width=1pt, color=black] (a.north) .. controls +(north:\jumpheight mm) and +(north:\jumpheight mm) .. node[above=2pt,text height=12pt,font=\large]{$\changevaltxt$} (b.north);
% equation at right end
\node [font=\large, minimum width=30mm] at (11.0,1.2) {$\equtxt$};
\end{tikzpicture}
\end{document}
2.3.6. Document๏
\begin{document}
starts the body of the document. It is used to indicate the beginning of the text that will be typeset to appear in the output pdf.\end{document}
command marks the end of the document2.3.7. tikzpicture๏
\begin{tikzpicture}
is a command in LaTeX that creates a new picture environment.2.3.8. Diagram parts๏
These LaTeX lines create a graphic element using the tikzpicture environment, which is part of the TikZ package for creating diagrams. The lines do the following:
\begin{tikzpicture}[scale=0.75]
starts the tikzpicture environment and sets the scale option to 0.80, which means that the graphic will be scaled down by 20%. This enables the line to be drawn with one tick every 1 cm before scaling it to fit on an A4 page.\draw[{To[scale=1.3]}-{To[scale=1.3]}, line width=1pt] (-10.4, 0) -- (10.4, 0)
draws a horizontal line from (-10.4, 0) to (10.4, 0) with a thickness of 1pt and arrow tips at both ends. The arrow tips are customized using the arrows.meta library and the To shape with a scale of 1.3.\foreach \x in {-10,-9,...,10}
starts a loop that assigns values to the variable x from -10 to 10 with increments of 1.\draw[shift={(\x,0)},color=black, line width=1pt] (0pt,-14pt) -- (0pt,0pt)
draws a vertical line segment from (0pt,-14pt) to (0pt,0pt) for each value of x, shifting the origin to (x,0) and using black color and 1pt thickness.\foreach \x in {-10,0,10}
starts another loop that assigns values to the variable x for -10, 0 and 10.\draw[shift={(\x,-0.8)},color=black] node[font=\large,text height=12pt] {$\x$}
places a node with the value of x below each tick mark on the horizontal axis, using a large font and a text height of 12pt.\draw[shift={(\startval,-0.8)},color=black] node[font=\large,text height=12pt] {$\startvaltxt$}
places a node with the value of\startvaltxt
below the tick mark corresponding to\startval
on the horizontal axis, using a large font and a text height of 12pt.\draw[shift={(\endval,-0.8)},color=black] node[font=\large,text height=12pt] {$\endvaltxt$}
places a node with the value of\endvaltxt
below the tick mark corresponding to\endval
on the horizontal axis, using a large font and a text height of 12pt.\filldraw[black] (\startval,0) circle (4pt) node[above,yshift=-2pt] (a) {}
fills and draws a black circle with a radius of 4pt at(\startval,0)
and names it(a)
. It also places an empty node above the circle with a vertical shift of -2pt.\filldraw[black] (\endval,0) circle (4pt) node[above,yshift=-2pt] (b) {}
fills and draws a black circle with a radius of 4pt at(\endval,0)
and names it(b)
. It also places an empty node above the circle with a vertical shift of -2pt.\draw[-{To[scale=1.3, bend]},line width=1pt, color=black] (a.north) .. controls +(north:\jumpheight mm) and +(north:\jumpheight mm) .. node[above=2pt,text height=12pt,font=\large]{$\changevaltxt$} (b.north)
draws a curved line from the north anchor of node(a)
to the north anchor of node(b)
, using an arrow tip at the end with a scale of 1.3 and a bend option that makes it follow the curvature of the path. The line has a thickness of 1pt and a black color. The curve is controlled by two points that are relative to the start and end points, using the + notation (see: https://en.wikibooks.org/wiki/LaTeX/PGF/TikZ#Specifying_coordinates). The points are shifted north by\jumpheight
mm. The line also has a node above it with a vertical shift of 2pt, a text height of 12pt, a large font, and the text\changevaltxt
.
2.4. number lines LaTeX๏
1% numberline
2\documentclass[preview, 12pt]{standalone}
3\usepackage{tikz}
4\usetikzlibrary{positioning}
5\usetikzlibrary {arrows.meta}
6\usetikzlibrary{bending}
7\usepackage[a4paper, portrait, margin=1cm]{geometry}
8
9\def\jumpheight{10}
10\def\qgap{\rule[-1pt]{1.0em}{.25pt}}
11
12% modify values for number lines
13\def\startval{-3}
14\def\endval{2}
15% values for display
16\def\startvaltxt{\qgap}
17\def\endvaltxt{\qgap}
18\def\changevaltxt{\qgap}
19\def\equtxt{\qgap + \qgap=\qgap}
20% end modify values for number lines
21
22\begin{document}
23\begin{tikzpicture}[scale=0.75]
24 % axis, arrow style to-to
25 \draw[{To[scale=1.3]}-{To[scale=1.3]}, line width=1pt] (-10.4, 0) -- (10.4, 0);
26 % tick marks
27 \foreach \x in {-10,-9,...,10}
28 \draw[shift={(\x,0)},color=black, line width=1pt] (0pt,-14pt) -- (0pt,0pt);
29 % numbers along each axis, \startval,\endval
30 \foreach \x in {-10,0,10}
31 \draw[shift={(\x,-0.8)},color=black] node[font=\large,text height=12pt] {$\x$};
32 \draw[shift={(\startval,-0.8)},color=black] node[font=\large,text height=12pt] {\startvaltxt};
33 \draw[shift={(\endval,-0.8)},color=black] node[font=\large,text height=12pt] {$\endvaltxt$};
34 % dots
35 \filldraw[black] (\startval,0) circle (4pt) node[above,yshift=-2pt] (a) {};
36 \filldraw[black] (\endval,0) circle (4pt) node[above,yshift=-2pt] (b) {};
37 % arrow
38 \draw[-{To[scale=1.3, bend]},line width=1pt, color=black] (a.north) .. controls +(north:\jumpheight mm) and +(north:\jumpheight mm) .. node[above=2pt,text height=10pt,font=\large] {$\changevaltxt$} (b.north);
39 % equation at right end
40 \node [font=\large, minimum width=30mm] at (11.0,1.2) {$\equtxt$};
41\end{tikzpicture}
42\end{document}
43
44
1% numberline
2\documentclass[preview,12pt]{standalone}
3\usepackage{tikz}
4\usetikzlibrary{positioning}
5\usetikzlibrary {arrows.meta}
6\usetikzlibrary{bending}
7\usepackage[a4paper, portrait, margin=1cm]{geometry}
8
9\def\jumpheight{10}
10\def\qgap{\rule[-1pt]{1.0em}{.25pt}}
11
12% modify values for number lines
13\def\startval{-3}
14\def\endval{2}
15% values for display
16\def\startvaltxt{\startval}
17\def\endvaltxt{\endval}
18\def\changevaltxt{+5}
19\def\equtxt{-3 + 5 = 2}
20% end modify values for number lines
21
22\begin{document}
23\begin{tikzpicture}[scale=0.75]
24 % axis, arrow style to-to
25 \draw[{To[scale=1.3]}-{To[scale=1.3]}, line width=1pt] (-10.4, 0) -- (10.4, 0);
26 % tick marks
27 \foreach \x in {-10,-9,...,10}
28 \draw[shift={(\x,0)},color=black, line width=1pt] (0pt,-14pt) -- (0pt,0pt);
29 % numbers along each axis
30 \foreach \x in {-10,0,10}
31 \draw[shift={(\x,-0.8)},color=black] node[font=\large,text height=12pt] {$\x$};
32 \draw[shift={(\startval,-0.8)},color=black] node[font=\large,text height=12pt] {$\startvaltxt$};
33 \draw[shift={(\endval,-0.8)},color=black] node[font=\large,text height=12pt] {$\endvaltxt$};
34 % dots
35 \filldraw[black] (\startval,0) circle (4pt) node[above,yshift=-2pt] (a) {};
36 \filldraw[black] (\endval,0) circle (4pt) node[above,yshift=-2pt] (b) {};
37 % arrow
38 \draw[-{To[scale=1.3, bend]},line width=1pt, color=black] (a.north) .. controls +(north:\jumpheight mm) and +(north:\jumpheight mm) .. node[above=2pt,text height=10pt,font=\large] {$\changevaltxt$} (b.north); % for addition
39 % equation at right end
40 \node [font=\large, minimum width=30mm] at (11.0,1.2) {$\equtxt$};
41\end{tikzpicture}
42\end{document}
43
44