Graphics, Figures & Tablesnumber line help

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Phooey
Posts: 5
Joined: Sun Sep 29, 2019 4:18 pm

number line help

Post by Phooey »

Hi Guys,

I am brand new to this forum and LaTeX in general. But I have now been tasked with writing the assessment materials for my employer so decided LaTeX was the way to go.

So I need to create this diagram. Please, I have spent all weekend trying to make sense of the google results I get. Can someone please suggest a simple piece of code with some brief explanation as to what is happening.

It is just the number line with the arrow. I am ok with the text and formatting.
Attachments
numberline.jpg
numberline.jpg (41.89 KiB) Viewed 3887 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

number line help

Post by Ijon Tichy »

Please can you show us, what you already have tried. The figure is so simple, that you even could make it with the standard picture environment:

Code: Select all

\documentclass{article}

\begin{document}
\setlength{\unitlength}{2mm}
\begin{picture}(60,10)(0,-10)
  \put(0,0){\line(1,0){60}}%
  \multiput(0,0)(1,0){61}{\line(0,-1){1}}%
  \multiput(0,0)(5,0){13}{\line(0,-1){2}}%
  \put(0,-2.5){\makebox(0,0)[ct]{0}}%
  \put(10,-2.5){\makebox(0,0)[ct]{10}}%
  \put(20,-2.5){\makebox(0,0)[ct]{20}}%
  \put(30,-2.5){\makebox(0,0)[ct]{30}}%
  \put(40,-2.5){\makebox(0,0)[ct]{40}}%
  \put(50,-2.5){\makebox(0,0)[ct]{50}}%
  \put(60,-2.5){\makebox(0,0)[ct]{60}}%
  \put(37,-10){\vector(0,1){8}}%
\end{picture}
\end{document}
The picture environment that should be explained in every complete LaTeX introduction, so please read one. You won't become happy with latex only using google search instead of reading a good introduction.

However, I would recommend to use pgf/TikZ instead of picture even for simple figures. Because it would be a good choice to learn TikZ step by step.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Phooey
Posts: 5
Joined: Sun Sep 29, 2019 4:18 pm

number line help

Post by Phooey »

That is absolutely perfect. Thank you so much.

I haven't saved anything that I have tried but essentially, I have tried drawing vertical and then horizontal lines and adding numbers - a complete mess!

I tried nodes but only managed to get a line with numbers and couldn't work out how to get the gradations.

I will look for a decent tikz tutorial book. I've managed to get some basics from YouTube vids but only managed to put together a simple document, a document that looks nice but very little in the way of graphics.

Oddly, I could managed to put together a calculus paper - my next job - but making 'pictures' isn't so easy.

Thank you again. I really appreciate you taking the time.

Edit: I will download the resource you suggested!
Post Reply