Jumat, 25 Oktober 2024

Number Line In Latex 2

  1. type this following latex code in Latex editor for drawing a number line:
%!TEX TS-program=pdflatex
%!TEX encoding=UTF-8 Unicode
\documentclass[tikz,margin=0.25cm]{standalone}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{arrows}

% Number line in Latex
\begin{document}
\begin{tikzpicture}
\draw[latex-latex,ultra thick](-6,0) -- (6,0); % edit here for the axis line

% edit here for vertical lines
\foreach \x in {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5} 
\draw[shift={(\x,0)},color=black] (0pt, 3pt) -- (0pt, -3pt);

% edit here for the below numbers
\foreach \x in {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}
\draw[shift={(\x,0)}, color=black] (0pt, 0pt) -- (0pt, -3pt) node[below] {$\textbf{\x}$};

\draw[shift={(-1.7,0)}, color=black] (0pt, 0pt) -- (0pt, 3pt) node[above] {$\dfrac{\textbf{-3}}{\textbf{2}}$};

\draw[shift={(0.8,0)}, color=black] (0pt, 0pt) -- (0pt, 3pt) node[above] {$\dfrac{\textbf{3}}{\textbf{4}}$};

\draw[shift={(1.3,0)}, color=black] (0pt, 0pt) -- (0pt, 3pt) node[above] {$\sqrt{\mathbf{2}}$};

\draw[shift={(3.1,0)}, color=black] (0pt, 0pt) -- (0pt, 3pt) node[above] {$\pmb{\pi}$};
\end{tikzpicture}
\end{document}

  1. Save file as numberLine2.tex.

Output

number line in latex 2
number line in latex 2

Notes:

  • To see the more clear screenshot, click on the picture.





Related Post

Tidak ada komentar:

Posting Komentar

Various Other Posts