Hey guys,
I'm completely new to LaTeX and have thrown myself somewhat in the deep end when starting a maths course.
I would like some help creating a number line with another line above it. The higher of the two lines requires dots on either end; one filled and one not. Example attached.
Any pointers would be greatly appreciated. Thanks in advance.
Graphics, Figures & Tables ⇒ Number Line Help
NEW: TikZ book now 40% off at Amazon.com for a short time.

Number Line Help
It should be easier for beginners to create the drawing with pgf/TikZ. My solution uses pgfplots:
A possible replacement for the command
Code: Select all
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=3mm,
axis y line=none,
axis x line=center,
xtick align=outside,
xtick={-5,0,...,30},
xmin=-7, xmax=33,
ymin=0, ymax=1,
xlabel=$x$,
xlabel style={anchor=north}
]
\addplot [nodes=draw, circle, inner sep=1.5pt]
coordinates {(-5,.1) (25,.1)}
node [fill, at start] {}
node [fill=white] {}
;
\end{axis}
\end{tikzpicture}
\end{document}
\addplot
:Code: Select all
\draw [nodes=draw, circle, inner sep=1.5pt]
(-5,.1) node (filled) [fill] {}
(25,.1) node (open) {}
(filled) -- (open)
;
Number Line Help
This is perfect - thank you!
Just one more addition I need to may if you wouldn't mind. I need to include a label above the top line as below:
Just one more addition I need to may if you wouldn't mind. I need to include a label above the top line as below:
Number Line Help
Code: Select all
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[
dot/.style={draw, fill=#1, circle, inner sep=1.5pt},
filled/.style={dot},
open/.style={dot=white}
]
\begin{axis}[
x=3mm,
axis y line=none,
axis x line=center,
xtick align=outside,
xtick={-5,0,...,30},
xmin=-7, xmax=33,
ymin=0, ymax=1,
xlabel=$x$,
xlabel style={anchor=north}
]
\addplot [black]
coordinates {(-5,.1) (25,.1)}
node [filled, at start] {}
node [open] {}
node [above, midway] {A}
;
\end{axis}
\end{tikzpicture}
\end{document}
Code: Select all
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[
dot/.style={draw, circle, inner sep=1.5pt},
filled/.style={dot, fill},
open/.style={dot}
]
\begin{axis}[
x=3mm,
axis y line=none,
axis x line=center,
xtick align=outside,
xtick={-5,0,...,30},
xmin=-7, xmax=33,
ymin=0, ymax=1,
xlabel=$x$,
xlabel style={anchor=north}
]
\draw
(-5,.1) node [filled] (filled) {}
(25,.1) node [open] (open) {}
(filled) -- node [above] {A} (open)
;
\end{axis}
\end{tikzpicture}
\end{document}
Last edited by Bartman on Wed Feb 26, 2020 2:33 am, edited 1 time in total.