Graphics, Figures & Tables ⇒ Number Lines with TikZ
-
- Posts: 139
- Joined: Tue Mar 10, 2015 11:06 am
Number Lines with TikZ
This shows the kind of worksheets I'm trying to create. (Student writing in blue.)
How should I get started learning TikZ?
Also, how do I put images directly into these threads?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Number Lines with TikZ
Code: Select all
% ----- embed.tex ------
\documentclass{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{center}
\setlength\PreviewBorder{10pt}
%
%====================================================
\begin{document}
\begin{center}
%-------------------------------
% Fill here -> tikzpicture CODE
\tikz\foreach \x [evaluate=\x as \shade using \x*8] in {0,1,...,8}
\node [fill=red!\shade!yellow, minimum size=0.65cm] at (\x,0) {$\frac{\x}{2}$};
% --- End filling tikzpicture CODE ---
\end{center}
\end{document}
%====================================================
%--- EOF: embed.tex --------
- Attachments
-
- scrsht.png (5.74 KiB) Viewed 8858 times
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Number Lines with TikZ
The best source is the (huge) TikZ manual. You can open it on your computer by typingLaTexLearner wrote:How should I get started learning TikZ?
texdoc tikz
or texdoc pgf
at the command prompt.You could start with the tutorial chapter.
As you did, you attached an image and clicked the link to put it inline.LaTexLearner wrote:Also, how do I put images directly into these threads?
Perhaps people would continue your code, if you started something, such as drawing a line. I mean, why should each reader want to type a document frame for answering with working code. The more you provide, the easier you make it for readers, the better the chance to get a solution for more complex things.
Stefan
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Number Lines with TikZ
Code: Select all
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
% The next macro calculates the first argument and uses that position
% to print the next argument
\newcommand*{\fractionprint}[2]{%
\pgfmathparse{#1}
\node at (\pgfmathresult,0.5) {$#2$};}
\begin{document}
\begin{tikzpicture}
\draw[latex-latex] (-2,0) -- (3,0);% the x-axis
\foreach \x in {-1,...,2} % tick marks
\draw (\x,0) -- (\x,-3pt);
\foreach \x in {-1,...,3} % the numbers
\node [below] at (\x,-0.1) {$\x$};
\fractionprint{1/2}{\frac{1}{2}}
\fractionprint{1+3/4}{1\frac{3}{4}}
\fractionprint{2+1/3}{2\frac{1}{3}}
\end{tikzpicture}
\end{document}
-
- Posts: 139
- Joined: Tue Mar 10, 2015 11:06 am
Number Lines with TikZ
When you say it's too heavy to learn, can you suggest another way of making those graphics?Sundial wrote:Please, let me know if the enclosed example is satisfactory as first approach. TikZ environment is highly powerful, but too heavy to learn. The 2-row code has been adapted from the monumental guide of Till Tantau (the inventor of TikZ), p. 913 (over 1165): TikZ&PGF,version 3.0.0, 2013 edition. Cheers
The Tikz code in this thread does look very complicated.
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: Number Lines with TikZ
The TikZ/pgf combo is very very powerful, the manual has more than a thousand pages. This can be very intimidating. But is has a quiete good tutorial as well, that gives you some of the basics. The rest is done by daily use, i guess. If you have many graphics, you will enjoy TikZ.
If you have only a handful, you might just as well produce the images with a vector-graphics program. Inkscape is available for free. It also has a TikZ export accessile via a plugin. This might be worth a look.
-
- Posts: 139
- Joined: Tue Mar 10, 2015 11:06 am
Number Lines with TikZ
When you say "tutorial" are you referring to the "TikZ and PGF Manual for Version 3.0.0" by Till Tantau? I just downloaded it... lol it looks monstrous, lol.Johannes_B wrote:Too hard to learn seems a bit exaggerated, as there are many users of TikZ.
The TikZ/pgf combo is very very powerful, the manual has more than a thousand pages. This can be very intimidating. But is has a quiete good tutorial as well, that gives you some of the basics. The rest is done by daily use, i guess. If you have many graphics, you will enjoy TikZ.
If you have only a handful, you might just as well produce the images with a vector-graphics program. Inkscape is available for free. It also has a TikZ export accessile via a plugin. This might be worth a look.
I expect to have about ~200 pages of materials, much of which will be images, though many of those images will be the similar. Probably 4 or 5 templates with many variations on each. Sounds like too many for Inkscape?
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Number Lines with TikZ
Sure, because it's very capable and well documented with a lot of examples. One can get started with reading a short tutorial section and using the rest as a reference. No need to read hundreds of pages of libraries which you don't use.LaTexLearner wrote:it looks monstrous
Large manuals a great. The more explained, the better. The more examples, the better. The more powerful package, the better. It's hardly understandable to reject a long manual just because of the size. I guess you did not mean it that way.
A strong point of TikZ is that you can "program" 4 or 5 templates and generate a hundred pictures with variations of them. One can use Inkscape with copy & paste, but it's not native LaTeX and especially TikZ styles can be changed globally and consistently with a few clicks in the style definition, while with Inkscape it's hard to modify the appearance of a hundred images.LaTexLearner wrote:I expect to have about ~200 pages of materials, much of which will be images, though many of those images will be the similar. Probably 4 or 5 templates with many variations on each. Sounds like too many for Inkscape?
So, a few and different images: Inkscape. A lot of similar images: TikZ - once created the base drawings the re-using is easy. Though it requires some reading and learning.
Stefan
-
- Posts: 139
- Joined: Tue Mar 10, 2015 11:06 am
Re: Number Lines with TikZ
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Number Lines with TikZ
Sure, I just see it often from others and it reminds meLaTexLearner wrote:not rejecting the manual on the basis of length

Let's say, it's for people using LaTeX already. Programming means too much. It uses LaTeX syntax and adds its own syntax which is quite nice I think.LaTexLearner wrote:Perhaps the manual is written for people who already know LaTeX and programming already?
To show that it got popular and to compare the trend with the other great LaTeX drawing package PSTricks, you could use google trends. Here's a screenshot, showing the red TikZ rising:
Stefan