Kamis, 13 Maret 2025

Number Line In Latex 6

1. type this following latex code in Latex editor for drawing a number line:
% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode
% Distributed under the LaTeX Project Public License
% https://www.latex-project.org/lppl.txt
% pdflatex numberLineText2.tex
%% A descriptive text on a number line

\documentclass[12pt]{article}
\usepackage[left=0.1cm,right=0.1cm,top=0.5cm,bottom=0.5cm]{geometry}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, 
                decorations.pathreplacing,%
                    calligraphy,% had to be after decorations.pathreplacing
                calc}

\usepackage[active,multi,tightpage,varwidth,pdflatex]{preview}
\PreviewEnvironment[{[]}]{tikzpicture}
\setlength\PreviewBorder{3pt}

\begin{document}
    \begin{tikzpicture}[
             > = Straight Barb,
BC/.style args = {#1/#2}{
        decorate,
        decoration={calligraphic brace, amplitude=6pt,
                    pre =moveto, pre  length=1pt,
                    post=moveto, post length=1pt,
                    raise=#1,
                    #2,% for mirroring of brace
                    },
            ultra thick},
                        ]
%% draw axes line / number line
\draw [thick,-] (-1,0) -- (13,0);
%% draw number label and vertical line for each number label
    \foreach \i [count=\x from 0] in  {1,5,20,150,\dotsm,75,50}
\draw[thick, -stealth,font=\bfseries,shift={(\x-0.1,0)}] (\x,3mm) node(n\x) [above] {$\mathbf{\i}$} -| (\x,-6mm) node (n\x) [below] {{\scriptsize datum}};

%% descriptive text in above
\draw[BC=4mm/,yshift=5mm]   (0,0) -- node[above=6mm] {\bfseries data number} (12,0); 
%%% descriptive text in below
\draw[BC=8mm/mirror,yshift=-5mm]    (-1,0) -- coordinate[below=51mm] (aux) (13,0);
\draw (6,-1.5) node[below]  {\bfseries data};
  
    \end{tikzpicture}
\end{document}
2. Save file as numberLineText2.tex.
3.Then build or typeset the Latex code.

Output

To see the output, look at the below picture:

Notes

To see the more clear picture, click on the picture.
Maybe you need a little bit high computer requirement to learn from above lesson list.




Tidak ada komentar:

Posting Komentar